url.pathToFileURL doesn't generate valid URLs for UNC paths #34736
Closed
Description
-
Node.js version: v12.18.3 and v14.8.0
-
Platform: Windows 10 (10.0.19041)
-
Subsystem:
url
What steps will reproduce the bug?
const url = require("url")
url.pathToFileURL("\\\\laptop\\My Documents\\FileSchemeURIs.doc")
Expected behavior
As per Microsoft's UNC URI documentation):
file://laptop/My%20Documents/FileSchemeURIs.doc
Actual behavior
URL {
href: 'file:///laptop/My%20Documents/FileSchemeURIs.doc',
origin: 'null',
protocol: 'file:',
username: '',
password: '',
host: '',
hostname: '',
port: '',
pathname: '/laptop/My%20Documents/FileSchemeURIs.doc',
search: '',
searchParams: URLSearchParams {},
hash: ''
}
-
hostname
should belaptop
(not''
). -
pathname
should be/My%20Documents/FileSchemeURIs.doc
(not be prefixed by/laptop/
).
Activity