FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

url: add fileURLToPathBuffer API by jasnell · Pull Request #58700 · nodejs/node · GitHub

/ node Public

url: add fileURLToPathBuffer API - #58700

Closed
jasnell wants to merge 1 commit into
nodejs:mainfrom
jasnell:jasnell/add-fileurltopathbuffer
Closed

url: add fileURLToPathBuffer API#58700
jasnell wants to merge 1 commit into
nodejs:mainfrom
jasnell:jasnell/add-fileurltopathbuffer

Conversation

jasnell commented Jun 12, 2025

Copy link
Copy Markdown
Member

The existing fileURLToPath() does not handle the case where the input URL contains percent-encoded characters that are not valid UTF-8 sequences. This can lead to issues, for instance, when the URL is constructed using file names in non-Unicode encodings (like Shift-JIS). This commit introduces a new API, fileURLToPathBuffer(), which returns a Buffer representing the path, allowing for accurate conversion of file URLs to paths without attempting to decode the percent-encoded bytes into characters.

This is part of the fix for #58634 but there's more to do.

jasnell added fs Issues and PRs related to the fs subsystem / file system. url Issues and PRs related to the legacy built-in url module. semver-minor PRs that contain new features and should be released in the next minor version. labels Jun 12, 2025

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/startup
  • @nodejs/url

nodejs-github-bot added needs-ci PRs that need a full CI run. whatwg-url Issues and PRs related to the WHATWG URL implementation. labels Jun 12, 2025

This comment was marked as outdated.

jasnell force-pushed the jasnell/add-fileurltopathbuffer branch 2 times, most recently from 249ab0d to 8ccd48d Compare June 12, 2025 20:59

This comment was marked as outdated.

Copy link
Copy Markdown
Collaborator

codecov Bot commented Jun 12, 2025
edited
Loading

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 48.76033% with 62 lines in your changes missing coverage. Please review.

Project coverage is 90.12%. Comparing base (5e1537c) to head (e362a1e).
Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/url.js 47.45% 62 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #58700      +/-   ##
==========================================
- Coverage   90.16%   90.12%   -0.04%     
==========================================
  Files         637      637              
  Lines      188098   188122      +24     
  Branches    36905    36898       -7     
==========================================
- Hits       169601   169548      -53     
- Misses      11231    11319      +88     
+ Partials     7266     7255      -11     
Files with missing lines Coverage Δ
lib/internal/data_url.js 100.00% <100.00%> (+8.23%) ⬆️
lib/url.js 100.00% <100.00%> (ø)
lib/internal/url.js 94.38% <47.45%> (-3.48%) ⬇️

... and 47 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

jasnell force-pushed the jasnell/add-fileurltopathbuffer branch from 803aa96 to cb63900 Compare June 12, 2025 22:54

nodejs-github-bot commented Jun 12, 2025
edited by jasnell
Loading

Copy link
Copy Markdown
Collaborator

Comment thread lib/internal/url.js Outdated
Comment thread lib/internal/url.js Outdated
Comment thread lib/internal/url.js Outdated

mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

lgtm

what could we do with this buffer? How could a user manipulate this?

jasnell force-pushed the jasnell/add-fileurltopathbuffer branch from cb63900 to 755e985 Compare June 14, 2025 14:23

jasnell commented Jun 14, 2025

Copy link
Copy Markdown
Member Author

what could we do with this buffer?

It can be passed directly to node:fs APIs. More importantly tho, it's to help fix the issue discussed in #58634 by making it possible to normalize the arguments passed into the filter callback.

This comment was marked as outdated.

Ethan-Arrowood left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I wont block on my one change recommendation, but please consider it in regards to consistency with path.win32 and path.posix pattern.

Comment thread doc/api/url.md Outdated
jasnell added the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Jun 14, 2025
The existing `fileURLToPath()` does not handle the case
where the input URL contains percent-encoded characters
that are not valid UTF-8 sequences. This can lead to
issues, for instance, when the URL is constructed
using file names in non-Unicode encodings (like
Shift-JIS). This commit introduces a new API,
`fileURLToPathBuffer()`, which returns a `Buffer`
representing the path, allowing for accurate
conversion of file URLs to paths without attempting
to decode the percent-encoded bytes into characters.
nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Jun 14, 2025

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/58700
✔  Done loading data for nodejs/node/pull/58700
----------------------------------- PR info ------------------------------------
Title      url: add fileURLToPathBuffer API (#58700)
Author     James M Snell <jasnell@gmail.com> (@jasnell)
Branch     jasnell:jasnell/add-fileurltopathbuffer -> nodejs:main
Labels     fs, url, semver-minor, whatwg-url, author ready, needs-ci
Commits    1
 - url: add fileURLToPathBuffer API
Committers 1
 - James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/58700
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/58700
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Thu, 12 Jun 2025 20:49:22 GMT
   ✔  Approvals: 3
   ✔  - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/58700#pullrequestreview-2927770869
   ✔  - Ethan Arrowood (@Ethan-Arrowood): https://github.com/nodejs/node/pull/58700#pullrequestreview-2928406839
   ✔  - LiviaMedeiros (@LiviaMedeiros): https://github.com/nodejs/node/pull/58700#pullrequestreview-2928714008
   ✘  Last GitHub CI failed
   ℹ  Last Full PR CI on 2025-06-14T19:33:13Z: https://ci.nodejs.org/job/node-test-pull-request/67444/
- Querying data for job/node-test-pull-request/67444/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/15656016109

jasnell added a commit that referenced this pull request Jun 14, 2025
The existing `fileURLToPath()` does not handle the case
where the input URL contains percent-encoded characters
that are not valid UTF-8 sequences. This can lead to
issues, for instance, when the URL is constructed
using file names in non-Unicode encodings (like
Shift-JIS). This commit introduces a new API,
`fileURLToPathBuffer()`, which returns a `Buffer`
representing the path, allowing for accurate
conversion of file URLs to paths without attempting
to decode the percent-encoded bytes into characters.

PR-URL: #58700
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: LiviaMedeiros <livia@cirno.name>

jasnell commented Jun 14, 2025

Copy link
Copy Markdown
Member Author

Landed in 3f6ad56

jasnell closed this Jun 14, 2025
targos pushed a commit that referenced this pull request Jun 16, 2025
The existing `fileURLToPath()` does not handle the case
where the input URL contains percent-encoded characters
that are not valid UTF-8 sequences. This can lead to
issues, for instance, when the URL is constructed
using file names in non-Unicode encodings (like
Shift-JIS). This commit introduces a new API,
`fileURLToPathBuffer()`, which returns a `Buffer`
representing the path, allowing for accurate
conversion of file URLs to paths without attempting
to decode the percent-encoded bytes into characters.

PR-URL: #58700
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
nodejs-github-bot added a commit that referenced this pull request Jun 16, 2025
Notable changes:

doc:
  * add islandryu to collaborators (Shima Ryuhei) #58714
fs:
  * (SEMVER-MINOR) allow correct handling of burst in fs-events with AsyncIterator (Philipp Dunkel) #58490
module:
  * (SEMVER-MINOR) remove experimental warning from type stripping (Marco Ippolito) #58643
test_runner:
  * (SEMVER-MINOR) support object property mocking (Idan Goshen) #58438
url:
  * (SEMVER-MINOR) add fileURLToPathBuffer API (James M Snell) #58700

PR-URL: #58727
nodejs-github-bot added a commit that referenced this pull request Jun 23, 2025
Notable changes:

doc:
  * add islandryu to collaborators (Shima Ryuhei) #58714
fs:
  * (SEMVER-MINOR) allow correct handling of burst in fs-events with AsyncIterator (Philipp Dunkel) #58490
module:
  * (SEMVER-MINOR) remove experimental warning from type stripping (Marco Ippolito) #58643
test_runner:
  * (SEMVER-MINOR) support object property mocking (Idan Goshen) #58438
url:
  * (SEMVER-MINOR) add fileURLToPathBuffer API (James M Snell) #58700

PR-URL: #58804
nodejs-github-bot added a commit that referenced this pull request Jun 24, 2025
Notable changes:

doc:
  * add islandryu to collaborators (Shima Ryuhei) #58714
fs:
  * (SEMVER-MINOR) allow correct handling of burst in fs-events with AsyncIterator (Philipp Dunkel) #58490
module:
  * (SEMVER-MINOR) remove experimental warning from type stripping (Marco Ippolito) #58643
test:
  * fix test-timeout-flag after revert of auto subtest wait (Pietro Marchini) #58282
test_runner:
  * Revert "test_runner: remove promises returned by t.test() (Romain Menke) #58282
  * Revert "test_runner: remove promises returned by test() (Romain Menke) #58282
  * Revert "test_runner: automatically wait for subtests to finish (Romain Menke) #58282
  * (SEMVER-MINOR) support object property mocking (Idan Goshen) #58438
url:
  * (SEMVER-MINOR) add fileURLToPathBuffer API (James M Snell) #58700

PR-URL: #58813
RafaelGSS added a commit that referenced this pull request Jun 24, 2025
Notable changes:

doc:
  * add islandryu to collaborators (Shima Ryuhei) #58714
fs:
  * (SEMVER-MINOR) allow correct handling of burst in fs-events with AsyncIterator (Philipp Dunkel) #58490
module:
  * (SEMVER-MINOR) remove experimental warning from type stripping (Marco Ippolito) #58643
test:
  * fix test-timeout-flag after revert of auto subtest wait (Pietro Marchini) #58282
test_runner:
  * (SEMVER-MINOR) support object property mocking (Idan Goshen) #58438
url:
  * (SEMVER-MINOR) add fileURLToPathBuffer API (James M Snell) #58700

PR-URL: #58813
RafaelGSS added a commit that referenced this pull request Jun 24, 2025
Notable changes:

doc:
  * add islandryu to collaborators (Shima Ryuhei) #58714
fs:
  * (SEMVER-MINOR) allow correct handling of burst in fs-events with AsyncIterator (Philipp Dunkel) #58490
module:
  * (SEMVER-MINOR) remove experimental warning from type stripping (Marco Ippolito) #58643
test:
  * fix test-timeout-flag after revert of auto subtest wait (Pietro Marchini) #58282
test_runner:
  * (SEMVER-MINOR) support object property mocking (Idan Goshen) #58438
url:
  * (SEMVER-MINOR) add fileURLToPathBuffer API (James M Snell) #58700

PR-URL: #58813
aduh95 pushed a commit that referenced this pull request Jul 21, 2025
The existing `fileURLToPath()` does not handle the case
where the input URL contains percent-encoded characters
that are not valid UTF-8 sequences. This can lead to
issues, for instance, when the URL is constructed
using file names in non-Unicode encodings (like
Shift-JIS). This commit introduces a new API,
`fileURLToPathBuffer()`, which returns a `Buffer`
representing the path, allowing for accurate
conversion of file URLs to paths without attempting
to decode the percent-encoded bytes into characters.

PR-URL: #58700
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
aduh95 pushed a commit that referenced this pull request Jul 24, 2025
The existing `fileURLToPath()` does not handle the case
where the input URL contains percent-encoded characters
that are not valid UTF-8 sequences. This can lead to
issues, for instance, when the URL is constructed
using file names in non-Unicode encodings (like
Shift-JIS). This commit introduces a new API,
`fileURLToPathBuffer()`, which returns a `Buffer`
representing the path, allowing for accurate
conversion of file URLs to paths without attempting
to decode the percent-encoded bytes into characters.

PR-URL: #58700
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
aduh95 added a commit that referenced this pull request Jul 28, 2025
Notable changes:

deps:
  * (SEMVER-MINOR) update amaro to 1.1.0 (Node.js GitHub Bot) #56350
doc:
  * add islandryu to collaborators (Shima Ryuhei) #58714
esm:
  * (SEMVER-MINOR) implement `import.meta.main` (Joe) #57804
fs:
  * (SEMVER-MINOR) allow correct handling of burst in fs-events with AsyncIterator (Philipp Dunkel) #58490
module:
  * (SEMVER-MINOR) remove experimental warning from type stripping (Marco Ippolito) #56350
  * (SEMVER-MINOR) unflag `--experimental-strip-types` (Marco Ippolito) #56350
permission:
  * (SEMVER-MINOR) propagate permission model flags on spawn (Rafael Gonzaga) #58853
sqlite:
  * (SEMVER-MINOR) add support for `readBigInts` option in db connection level (Miguel Marcondes Filho) #58697
src,permission:
  * (SEMVER-MINOR) add support to `permission.has(addon)` (Rafael Gonzaga) #58951
url:
  * (SEMVER-MINOR) add `fileURLToPathBuffer` API (James M Snell) #58700
watch:
  * (SEMVER-MINOR) add `--watch-kill-signal` flag (Dario Piotrowicz) #58719
worker:
  * (SEMVER-MINOR) make `Worker` async disposable (James M Snell) #58385

PR-URL: #59256
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
aduh95 added a commit that referenced this pull request Jul 31, 2025
Notable changes:

deps:
  * (SEMVER-MINOR) update amaro to 1.1.0 (Node.js GitHub Bot) #56350
doc:
  * add islandryu to collaborators (Shima Ryuhei) #58714
esm:
  * (SEMVER-MINOR) implement `import.meta.main` (Joe) #57804
fs:
  * (SEMVER-MINOR) allow correct handling of burst in fs-events with AsyncIterator (Philipp Dunkel) #58490
module:
  * (SEMVER-MINOR) remove experimental warning from type stripping (Marco Ippolito) #56350
  * (SEMVER-MINOR) unflag `--experimental-strip-types` (Marco Ippolito) #56350
permission:
  * (SEMVER-MINOR) propagate permission model flags on spawn (Rafael Gonzaga) #58853
sqlite:
  * (SEMVER-MINOR) add support for `readBigInts` option in db connection level (Miguel Marcondes Filho) #58697
src,permission:
  * (SEMVER-MINOR) add support to `permission.has(addon)` (Rafael Gonzaga) #58951
url:
  * (SEMVER-MINOR) add `fileURLToPathBuffer` API (James M Snell) #58700
watch:
  * (SEMVER-MINOR) add `--watch-kill-signal` flag (Dario Piotrowicz) #58719
worker:
  * (SEMVER-MINOR) make `Worker` async disposable (James M Snell) #58385

PR-URL: #59256
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
aduh95 added a commit that referenced this pull request Jul 31, 2025
Notable changes:

deps:
  * (SEMVER-MINOR) update amaro to 1.1.0 (Node.js GitHub Bot) #56350
doc:
  * add islandryu to collaborators (Shima Ryuhei) #58714
esm:
  * (SEMVER-MINOR) implement `import.meta.main` (Joe) #57804
fs:
  * (SEMVER-MINOR) allow correct handling of burst in fs-events with AsyncIterator (Philipp Dunkel) #58490
module:
  * (SEMVER-MINOR) remove experimental warning from type stripping (Marco Ippolito) #56350
  * (SEMVER-MINOR) unflag `--experimental-strip-types` (Marco Ippolito) #56350
permission:
  * (SEMVER-MINOR) propagate permission model flags on spawn (Rafael Gonzaga) #58853
sqlite:
  * (SEMVER-MINOR) add support for `readBigInts` option in db connection level (Miguel Marcondes Filho) #58697
src,permission:
  * (SEMVER-MINOR) add support to `permission.has(addon)` (Rafael Gonzaga) #58951
url:
  * (SEMVER-MINOR) add `fileURLToPathBuffer` API (James M Snell) #58700
watch:
  * (SEMVER-MINOR) add `--watch-kill-signal` flag (Dario Piotrowicz) #58719
worker:
  * (SEMVER-MINOR) make `Worker` async disposable (James M Snell) #58385

PR-URL: #59256
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
mete0rfish pushed a commit to mete0rfish/node-contribute that referenced this pull request Aug 9, 2025
Notable changes:

deps:
  * (SEMVER-MINOR) update amaro to 1.1.0 (Node.js GitHub Bot) nodejs#56350
doc:
  * add islandryu to collaborators (Shima Ryuhei) nodejs#58714
esm:
  * (SEMVER-MINOR) implement `import.meta.main` (Joe) nodejs#57804
fs:
  * (SEMVER-MINOR) allow correct handling of burst in fs-events with AsyncIterator (Philipp Dunkel) nodejs#58490
module:
  * (SEMVER-MINOR) remove experimental warning from type stripping (Marco Ippolito) nodejs#56350
  * (SEMVER-MINOR) unflag `--experimental-strip-types` (Marco Ippolito) nodejs#56350
permission:
  * (SEMVER-MINOR) propagate permission model flags on spawn (Rafael Gonzaga) nodejs#58853
sqlite:
  * (SEMVER-MINOR) add support for `readBigInts` option in db connection level (Miguel Marcondes Filho) nodejs#58697
src,permission:
  * (SEMVER-MINOR) add support to `permission.has(addon)` (Rafael Gonzaga) nodejs#58951
url:
  * (SEMVER-MINOR) add `fileURLToPathBuffer` API (James M Snell) nodejs#58700
watch:
  * (SEMVER-MINOR) add `--watch-kill-signal` flag (Dario Piotrowicz) nodejs#58719
worker:
  * (SEMVER-MINOR) make `Worker` async disposable (James M Snell) nodejs#58385

PR-URL: nodejs#59256
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no outstanding review comments, and a CI started. commit-queue-failed An error occurred while landing this pull request using GitHub Actions. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version. url Issues and PRs related to the legacy built-in url module. whatwg-url Issues and PRs related to the WHATWG URL implementation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants


Back | FazBrowse Home | New Git URL