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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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 75.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 88.54%. Comparing base (0d00511) to head (6708d1c).
Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/url.js 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #56302      +/-   ##
==========================================
+ Coverage   88.04%   88.54%   +0.50%     
==========================================
  Files         657      657              
  Lines      190290   190290              
  Branches    36245    36531     +286     
==========================================
+ Hits       167536   168496     +960     
+ Misses      15893    14983     -910     
+ Partials     6861     6811      -50     
Files with missing lines Coverage Δ
lib/internal/url.js 97.66% <75.00%> (+1.89%) ⬆️

... and 91 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);

@@ -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

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.
6 participants