deno
46678500 - fix(ext/node): encode more chars in url.pathToFileURL() (#33397)

Commit
117 days ago
fix(ext/node): encode more chars in url.pathToFileURL() (#33397) ## Summary - Extends `encodePathChars` in `ext/node/polyfills/url.ts` to percent-encode `^`, `[`, `]`, `|`, and `~` — characters that WHATWG URL's pathname setter leaves unencoded but that Node.js's `pathToFileURL` encodes. - Fixes handling of the Windows extended-path prefix `\\?\`: - `\\?\C:\...` strips the prefix and is treated as a regular drive path (matches Node's `file:///C:/...` instead of ending up with `?` as the hostname). - `\\?\UNC\server\share\...` is now recognized as an extended UNC path; hostname is parsed from after the `\\?\UNC\` prefix. - Rewrites regular UNC parsing to use `indexOf` on the host-end backslash instead of `split("\\\\")`, which is both faster and correctly rejects empty-hostname inputs. - Enables `parallel/test-url-pathtofileurl.js` in the node_compat suite. ## Test plan - [x] `cargo test --test node_compat -- test-url-pathtofileurl` passes - [x] Previously-enabled URL tests in the node_compat suite still pass (`test-url-domain-ascii-unicode`, `test-url-fileurltopath`, `test-url-format-invalid-input`, `test-url-format-whatwg`, `test-url-format`, `test-url-parse-format`, `test-url-parse-query`, `test-url-relative`, `test-url-urltooptions`) - [x] `deno lint` and `deno fmt --check` pass on the modified file --------- Co-authored-by: Nathan Whitaker <nathan@deno.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Author
Parents
Loading