Skip to content

fix(ext/node): implement url.fileURLToPathBuffer#34883

Merged
crowlKats merged 1 commit into
mainfrom
fix/file-url-to-path-buffer
Jun 8, 2026
Merged

fix(ext/node): implement url.fileURLToPathBuffer#34883
crowlKats merged 1 commit into
mainfrom
fix/file-url-to-path-buffer

Conversation

@crowlbot

@crowlbot crowlbot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Adds the fileURLToPathBuffer export to node:url.

Like fileURLToPath, but returns the path as a Buffer of raw bytes obtained by percent-decoding the URL without interpreting the result as UTF-8. This allows recovering file paths that contain non-Unicode byte sequences (e.g. Shift-JIS file names) that fileURLToPath cannot decode.

Implements the WHATWG percent-decode algorithm operating on raw bytes, plus posix/win32 path extraction mirroring Node's getPathBufferFromURLPosix / getPathBufferFromURLWin32.

Enables parallel/test-fileurltopathbuffer.js in the node_compat suite, which round-trips a non-Unicode path:

const testPath = new URL('%82%A0%82%A2%82%A4', tmpdirUrl);
// fileURLToPath throws URIError on the non-UTF-8 sequence; the buffer variant succeeds.
assert.ok(existsSync(fileURLToPathBuffer(testPath)));

The target test passes locally (the upstream test skips on macOS and Windows). Adjacent node:url / fileurl tests are unaffected.

Adds the `fileURLToPathBuffer` export to node:url. Like fileURLToPath,
but returns the path as a Buffer of raw bytes obtained by percent-decoding
the URL without interpreting the result as UTF-8, allowing recovery of
paths that contain non-Unicode byte sequences.

Implements the WHATWG percent-decode algorithm (percentDecode) operating
on raw bytes, plus posix/win32 path extraction mirroring Node's
getPathBufferFromURLPosix / getPathBufferFromURLWin32.

Enables parallel/test-fileurltopathbuffer.js in the node_compat suite.
@crowlbot

crowlbot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

@crowlKats ready for review

@crowlKats
crowlKats merged commit aa78347 into main Jun 8, 2026
137 checks passed
@crowlKats
crowlKats deleted the fix/file-url-to-path-buffer branch June 8, 2026 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants