Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

url: use resolved path to convert to fileURL #56302

Merged
merged 3 commits into from
Dec 25, 2024

Conversation

aduh95
Copy link
Contributor

@aduh95 aduh95 commented Dec 18, 2024

Only matters if the CWD is a UNC path, which is hard to write a test for.

Fixes: #56262

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/url

@nodejs-github-bot 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 Dec 18, 2024
Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.

Project coverage is 88.54%. Comparing base (0d00511) to head (de54f8d).
Report is 40 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/url.js 81.81% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #56302      +/-   ##
==========================================
+ Coverage   88.04%   88.54%   +0.49%     
==========================================
  Files         657      657              
  Lines      190290   190398     +108     
  Branches    36245    36551     +306     
==========================================
+ Hits       167536   168580    +1044     
+ Misses      15893    14998     -895     
+ Partials     6861     6820      -41     
Files with missing lines Coverage Δ
lib/internal/url.js 97.67% <81.81%> (+1.89%) ⬆️

... and 104 files with indirect coverage changes

@aduh95 aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Dec 18, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 18, 2024
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@@ -1512,32 +1512,32 @@ function fileURLToPath(path, options = kEmptyObject) {

function pathToFileURL(filepath, options = kEmptyObject) {
const windows = options?.windows ?? isWindows;
if (windows && StringPrototypeStartsWith(filepath, '\\\\')) {
let resolved = windows ? path.win32.resolve(filepath) : path.posix.resolve(filepath);
Copy link
Member

Choose a reason for hiding this comment

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

Instead of introducing a new variable named resolved and renaming the existing parameter filepath, rename the input parameter to filepathOriginal and create a new variable filepath for the modified version of the original path.

Suggested change
let resolved = windows ? path.win32.resolve(filepath) : path.posix.resolve(filepath);
let filepath = windows ? path.win32.resolve(filepathOriginal) : path.posix.resolve(filepathOriginal);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not introducing it, it already exists; I'm only moving its declaration upper.

@@ -1512,32 +1512,32 @@ function fileURLToPath(path, options = kEmptyObject) {

function pathToFileURL(filepath, options = kEmptyObject) {
Copy link
Member

Choose a reason for hiding this comment

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

filepathOriginal or filepathUnresolved

@nodejs-github-bot
Copy link
Collaborator

@aduh95
Copy link
Contributor Author

aduh95 commented Dec 23, 2024

Let's not start another CI until I've investigated the Windows failure

lib/internal/url.js Outdated Show resolved Hide resolved
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 merged commit 1d1d8f2 into nodejs:main Dec 25, 2024
53 checks passed
@aduh95
Copy link
Contributor Author

aduh95 commented Dec 25, 2024

Landed in 1d1d8f2

@aduh95 aduh95 deleted the path2fileURL-from-unc-pwd branch December 25, 2024 18:42
@Jason3S
Copy link

Jason3S commented Dec 25, 2024

Thank you

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 pending requests for changes, and a CI started. needs-ci PRs that need a full CI run. whatwg-url Issues and PRs related to the WHATWG URL implementation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

url.pathToFileURL generates an incorrect file URL if the cwd is a UNC path.
8 participants