Основное различие (с точки зрения моего приложения) состоит в том, какими должны быть protocol
и pathname
.
Chrome говорит, что protocol
и pathname
равны file://
и /D:/file.txt
соответственно.
Firefox и Node говорят d:
и \\file.txt
.
Спецификация здесь, https://url.spec.whatwg.org/,, но я не смог понять, кто из этого прав.
Chrome 70
new URL("d:\\file.txt")
hash: ""
host: ""
hostname: ""
href: "file:///D:/file.txt"
origin: "file://"
password: ""
pathname: "/D:/file.txt"
port: ""
protocol: "file:"
search: ""
searchParams: URLSearchParams {}
username: ""
Firefox 63.0
new URL("d:\\file.txt")
hash: ""
host: ""
hostname: ""
href: "d:\\file.txt"
origin: "null"
password: ""
pathname: "\\file.txt"
port: ""
protocol: "d:"
search: ""
searchParams: URLSearchParams { }
username: ""
Узел 10.9.0
node -e "console.log(new URL('d:\\file.txt'))"
hash: ''
host: ''
hostname: ''
href: 'd:\\file.txt'
origin: 'null'
password: ''
pathname: '\\file.txt'
port: ''
protocol: 'd:'
search: ''
searchParams: URLSearchParams {}
username: ''