GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — url: fix case-insensitive extended UNC paths in pathToFileURL by ShakilUrRehman21 · Pull Request #67178 · nodejs/node

Conversation

@ShakilUrRehman21

@ShakilUrRehman21 ShakilUrRehman21 commented Nov 1, 2026

Copy link
Copy Markdown

Description

Windows paths and namespaces are case-insensitive. When using url.pathToFileURL(), extended UNC paths prefixed with lowercase \\?\unc\ or mixed-case \\?\Unc\ were not recognized as extended UNC because the implementation strictly checked for uppercase '\\\\?\\UNC\\'.

As a result:

  • The path was parsed as a standard UNC path with prefix length 2, extracting "?" as the hostname.
  • Ada / WHATWG URL parser stripped the invalid hostname to empty "", swallowing the server name as a directory in the pathname (file:///unc/server/share/file.txt).
  • Passing the resulting URL to fileURLToPath() threw a fatal TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must be absolute.

Additionally, extended UNC paths with empty servernames (e.g. \\?\UNC\\share or \\?\unc\\share) bypassed validation because the empty servername check was hardcoded to hostnameEndIndex === 2 instead of checking against prefixLength.

This PR:

  1. Updates pathToFileURL to match \\?\UNC\ case-insensitively using StringPrototypeToUpperCase.
  2. Updates the empty servername check to hostnameEndIndex === prefixLength, properly throwing ERR_INVALID_ARG_VALUE for empty extended UNC servernames.
  3. Adds test coverage for lowercase and mixed-case extended UNC paths, as well as empty extended UNC servernames and missing resource paths.

Refs: #54262
Refs: #56302

Checklist

  • test passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ShakilUrRehman21
url: fix case-insensitive extended UNC paths in pathToFileURL
a635d2b
Windows paths and namespaces are case-insensitive. Extended UNC paths
prefixed with `\\?\unc\` or mixed case like `\\?\Unc\` were not
recognized by `pathToFileURL` because it only checked for uppercase
`\\?\UNC\`. As a result, the UNC prefix was incorrectly handled as a
standard UNC path with an empty hostname, causing `fileURLToPath` to
throw ERR_INVALID_FILE_URL_PATH on the resulting URL.

Additionally, extended UNC paths with empty servernames (such as
`\\?\UNC\\share`) were bypassing validation because the empty
servername check was hardcoded to `hostnameEndIndex === 2` instead of
checking against `prefixLength`.

This commit updates `pathToFileURL` to:
- Match `\\?\UNC\` case-insensitively using
  `StringPrototypeToUpperCase`.
- Validate that `hostnameEndIndex !== prefixLength` before slicing
  the hostname, properly throwing ERR_INVALID_ARG_VALUE when the
  extended UNC servername is empty.
- Add test coverage for lowercase and mixed-case extended UNC paths
  and empty extended UNC servernames.

Signed-off-by: shakilurrehman21 <[email protected]>
@nodejs-github-bot

nodejs-github-bot commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/url
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@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 Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Welcome to Node.js, and thank you for your first contribution!

Before review, please take a moment to read:

  • the guide for first-time contributors
  • the contribution and automation policies
  • the pull request guide
  • the AI use policy
  • the Code of Conduct

Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MikeMcC399 MikeMcC399 mentioned this pull request Nov 1, 2026
buffer: add DataView support to isUtf8, isAscii, and stringLength #67179
Draft
4 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

needs-ci PRs that need a full CI run. whatwg-url Issues and PRs related to the WHATWG URL implementation.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@ShakilUrRehman21 @nodejs-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.