Join GitHub today
Drive letters get duplicated when resolving Windows file: URL with base #303
It seems like it's impossible to resolve a Windows file:/// URI with a base.
Expected (as implemented Chrome):
new URL('/c:/foo/bar', 'file:///c:/baz/qux').href "file:///C:/foo/bar"
Actual (as implemented in jsdom/whatwg-url, NodeJS 7, Edge):
new URL('/c:/foo/bar', 'file:///c:/baz/qux').href 'file:///c:/c:/foo/bar'
Why do they act like hosts? A file: URI can have a host before the path, the path starts with a leading slash just like on other OS. It's just like a mounted drive on Linux.
The drive letter definitely is not shown as a host in any implementation I tested:
new URL('/c:/foo/bar', 'file:///c:/baz/qux').host ''
Is this behaviour defined in the current spec?
I think a drive letter must act like "host" in the input as well. I.e. if input has a drive letter, then don't copy the drive letter from base. Because the same is done with hosts: if input contains a host, then host isn't copied from the base.
So I think @felixfbecker is right. It looks like spec. bug.