Skip to content

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

Open
HassanFleyah wants to merge 1 commit intonodejs:mainfrom
HassanFleyah:fix/windows-device-paths
Open

path: fix normalization of Windows device paths missing colon#61545
HassanFleyah wants to merge 1 commit 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 84.21053% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.68%. Comparing base (4579957) to head (86e06aa).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
lib/path.js 84.21% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #61545   +/-   ##
=======================================
  Coverage   89.67%   89.68%           
=======================================
  Files         676      676           
  Lines      206555   206567   +12     
  Branches    39554    39555    +1     
=======================================
+ Hits       185230   185250   +20     
+ Misses      13461    13451   -10     
- Partials     7864     7866    +2     
Files with missing lines Coverage Δ
lib/path.js 97.39% <84.21%> (-0.10%) ⬇️

... and 36 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
@HassanFleyah HassanFleyah force-pushed the fix/windows-device-paths branch 2 times, most recently from e01e1c1 to 1fb9ea6 Compare March 16, 2026 14:42
@HassanFleyah
Copy link
Author

Enhanced coverage with a new test suite, squashed all changes into a single commit, and updated the existing tests for better comprehensiveness. @Flarna could you please approve the pending workflows to trigger the CI checks?

@HassanFleyah HassanFleyah force-pushed the fix/windows-device-paths branch from 1fb9ea6 to ab22425 Compare March 16, 2026 20:07
@HassanFleyah
Copy link
Author

Fixed the no-lonely-if linter error. @Flarna , could you please approve the pending workflows to trigger the CI checks? Thank you

test: add test case for device paths missing colon

style: fix linter errors

path: fix normalization of Windows device paths missing colon
@HassanFleyah HassanFleyah force-pushed the fix/windows-device-paths branch from ab22425 to 86e06aa Compare March 16, 2026 20:34
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