SIGN IN SIGN UP
facebook / react-native UNCLAIMED

A framework for building native applications using React

0 0 0 C++

Align Flow lib defs for Node.js url with v24

Summary:
This is an AI-assisted change to align the Flow definitions for the `url` module with the Node.js docs as at v24.

**New Safe Parsing:**

1. **`URL.parse(input, base?)`** - Safe static parsing (added in v22.1.0)
   - Parses URL without throwing exceptions
   - Returns `URL` object on success, `null` on failure
   - Alternative to `new URL()` that doesn't require try-catch
   - Example: `const url = URL.parse(userInput); if (url) { ... }`
   - https://nodejs.org/api/url.html#urlparseinput-base

**New Pattern Matching (Experimental):**

2. **`URLPattern` class** - Web API-compatible URL pattern matching (added in v23.8.0) 🧪
   - Constructor: `new URLPattern(input?, options?)` or `new URLPattern(input, baseURL, options?)`
   - Properties: `protocol`, `username`, `password`, `hostname`, `port`, `pathname`, `search`, `hash`, `hasRegExpGroups` (all readonly)
   - Methods: 
     - `test(input?, baseURL?)` - Returns boolean if URL matches pattern
     - `exec(input?, baseURL?)` - Returns match result with captured groups or null
   - Supports wildcard patterns (`*`), named groups (`:param`), and case-insensitive matching
   - Use cases: routing, URL filtering, path matching
   - https://nodejs.org/api/url.html#class-urlpattern

**Enhanced Path Conversion:**

3. **`pathToFileURL(path, options?)`** - Enhanced with options (v20.0.0)
   - New optional `options` parameter: `{windows?: boolean}`
   - Enables cross-platform path conversion testing
   - https://nodejs.org/api/url.html#urlpathtofileurlpath-options

4. **`fileURLToPath(url, options?)`** - Enhanced with options (v20.0.0)
   - New optional `options` parameter: `{windows?: boolean}`
   - Enables cross-platform URL to path conversion testing
   - https://nodejs.org/api/url.html#urlfileurltopathurl-options

**Type Definitions Added:**

5. **`url$URLPatternInit`** - Pattern initialization object
   - Optional properties for each URL component
   - Used in URLPattern constructor and exec/test methods

6. **`url$URLPatternComponentResult`** - Pattern match result for URL component
   - Contains `input` string and captured `groups` object

7. **`url$URLPatternResult`** - Complete pattern match result
   - Contains match results for all URL components
   - Includes original inputs array

**References:**
- Node.js url module docs: https://nodejs.org/api/url.html
- URLPattern Web API spec: https://urlpattern.spec.whatwg.org/

Changelog: [Internal]
---
> Generated by [Confucius Code Assist (CCA)](https://www.internalfb.com/wiki/Confucius/Analect/Shared_Analects/Confucius_Code_Assist_(CCA)/)
[Confucius Session](https://www.internalfb.com/confucius?host=devvm45708.cln0.facebook.com&port=8086&tab=Chat&session_id=1a3aa26e-e5a9-11f0-8d47-71a4a90f0494&entry_name=Code+Assist), [Trace](https://www.internalfb.com/confucius?session_id=1a3aa26e-e5a9-11f0-8d47-71a4a90f0494&tab=Trace)

Reviewed By: vzaidman

Differential Revision: D89943253
R
Rob Hogan committed
ca2d244f22975bb1c82ce8d0f53be6588be9548c
Parent: 4862cc7
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> on 1/2/2026, 7:28:03 PM