Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drive letters get duplicated when resolving Windows file: URL with base #303

Closed
felixfbecker opened this Issue Apr 28, 2017 · 4 comments

Comments

3 participants
@felixfbecker
Copy link

felixfbecker commented Apr 28, 2017

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'

@annevk annevk added needs tests parser and removed needs tests labels Apr 28, 2017

@annevk

This comment has been minimized.

Copy link
Member

annevk commented Apr 28, 2017

Windows drive letters are somewhat magical (and act like hosts) so that's somewhat to be expected.

@felixfbecker

This comment has been minimized.

Copy link
Author

felixfbecker commented Apr 28, 2017

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?

@annevk

This comment has been minimized.

Copy link
Member

annevk commented Apr 28, 2017

Act like host doesn't mean exposed as one. It just means that when resolving URLs they act like a base.

new URL('/test', 'file:///c:/x').href
"file:///c:/test"
@rmisev

This comment has been minimized.

Copy link
Member

rmisev commented Apr 28, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.