Open
Description
Version
v20.10.0
Platform
Microsoft Windows NT 10.0.19045.0 x64
Subsystem
lib/path.js ("node:path/posix")
What steps will reproduce the bug?
When I normalize
a POSIX path with 'node:path/posix', if the path contains exactly two leading slashes, I'd expect the two leading slashes NOT to be collapsed to one, as per the POSIX spec (see [1]), but the opposite appears to happen.
Here is an example with CMD on Win 10:
C:\Users\Julio>node
Welcome to Node.js v20.10.0.
Type ".help" for more information.
> var $p = require("path/posix")
undefined
> $p.normalize("//alpha/beta")
'/alpha/beta'
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior? Why is that the expected behavior?
Expected result is '//alpha/beta'
, i.e. the two leading slashes are NOT collapsed to one.
What do you see instead?
Actual result is '/alpha/beta'
, where the two leading slashes have been collapsed to one.
Additional information
[1] See POSIX.1-2017 / Base Definitions / 3.271 Pathname, which states:
Multiple successive slash characters are considered to be the same as one slash, except for the case of exactly two leading slash characters.