path: fix normalization of Windows device paths missing colon#61545
path: fix normalization of Windows device paths missing colon#61545HassanFleyah wants to merge 1 commit intonodejs:mainfrom
Conversation
|
Review requested:
|
There was a problem hiding this comment.
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-casefirstPart === '.' || 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, usingWINDOWS_RESERVED_NAMESdirectly on the substring after the prefix.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Gentle reminder for the maintainers to authorize the pending workflows |
1 similar comment
|
Gentle reminder for the maintainers to authorize the pending workflows |
Codecov Report❌ Patch coverage is
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
🚀 New features to boost your workflow:
|
e01e1c1 to
1fb9ea6
Compare
|
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? |
1fb9ea6 to
ab22425
Compare
|
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
ab22425 to
86e06aa
Compare
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
\\.\CONand\\?\CONare 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.