Closed EarlyRiser42 closed 1 month ago
Reproduction:
$ node
Welcome to Node.js v22.5.1.
Type ".help" for more information.
> require('url').pathToFileURL('\\\\?\\UNC\\server\\share\\folder\\file.txt', { windows: false }).href;
'file:///<path>/%5C%5C%3F%5CUNC%5Cserver%5Cshare%5Cfolder%5Cfile.txt'
> require('url').pathToFileURL('\\\\?\\UNC\\server\\share\\folder\\file.txt', { windows: true }).href;
'file:///UNC/server/share/folder/file.txt'
Version
22.5.1
Platform
Subsystem
No response
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Anytime
What is the expected behavior? Why is that the expected behavior?
According to the Microsoft documentation on maximum file path limitations, the \?\UNC\ prefix are not used as part of the path itself. so it should be ignored when converting to a file URI. The current implementation does not adhere to this guideline, resulting in incorrect URL conversions. Its output should be
file://server/share/folder/file.txt.
What do you see instead?
file:///UNC/server/share/folder/file.txt
Additional information
No response