Skip to content

path: fix normalization of Windows device paths missing colon#61545

Open
HassanFleyah wants to merge 3 commits intonodejs:mainfrom
HassanFleyah:fix/windows-device-paths
Open

path: fix normalization of Windows device paths missing colon#61545
HassanFleyah wants to merge 3 commits intonodejs:mainfrom
HassanFleyah:fix/windows-device-paths

Conversation

@HassanFleyah
Copy link

Description

This PR fixes an inconsistency in path.win32.normalize() where Windows reserved device names prefixed with \\.\ or \\?\ were not being correctly detected if they lacked a trailing colon.

Current behavior:

  • path.normalize('\\\\.\\CON:') -> Correctly handled/sanitized.
  • path.normalize('\\\\.\\CON') -> Returned as-is (Inconsistent).

This change ensures that \\.\CON and \\?\CON are treated consistently with other device paths by strictly checking against the reserved names list when the namespace prefix is present but the colon is missing.

Context

This addresses an edge case where valid Windows device paths bypass normalization logic due to the missing colon expectation.

Testing

I have verified this fix locally.

Copilot AI review requested due to automatic review settings January 27, 2026 14:03
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/path

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. path Issues and PRs related to the path subsystem. labels Jan 27, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR tightens path.win32.normalize() handling for Windows device paths so that reserved device names prefixed with \\.\ or \\?\ are correctly detected even when the trailing colon is missing. It aims to close an edge case where such paths could bypass existing normalization logic.

Changes:

  • Refactors the UNC/device-root detection branch in win32.normalize() to special-case firstPart === '.' || firstPart === '?' for device roots.
  • Adds new logic to detect reserved device names when a \\.\ or \\?\ namespace prefix is present but the path lacks a colon, using WINDOWS_RESERVED_NAMES directly on the substring after the prefix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@HassanFleyah
Copy link
Author

Gentle reminder for the maintainers to authorize the pending workflows

1 similar comment
@HassanFleyah
Copy link
Author

Gentle reminder for the maintainers to authorize the pending workflows

@codecov
Copy link

codecov bot commented Feb 21, 2026

Codecov Report

❌ Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.78%. Comparing base (720feff) to head (6ffabb1).
⚠️ Report is 190 commits behind head on main.

Files with missing lines Patch % Lines
lib/path.js 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #61545      +/-   ##
==========================================
- Coverage   89.79%   89.78%   -0.01%     
==========================================
  Files         672      673       +1     
  Lines      203809   203831      +22     
  Branches    39187    39174      -13     
==========================================
  Hits       183004   183004              
- Misses      13123    13153      +30     
+ Partials     7682     7674       -8     
Files with missing lines Coverage Δ
lib/path.js 97.44% <93.75%> (-0.05%) ⬇️

... and 52 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.

@Flarna Flarna added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. review wanted PRs that need reviews. labels Feb 22, 2026
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. path Issues and PRs related to the path subsystem. review wanted PRs that need reviews.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants