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 · Fixed by #343
Closed

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

felixfbecker opened this issue Apr 28, 2017 · 4 comments · Fixed by #343

Comments

@felixfbecker
Copy link

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 Moving the issue forward requires someone to write tests topic: parser and removed needs tests Moving the issue forward requires someone to write tests labels Apr 28, 2017
@annevk
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
Copy link
Author

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
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
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.

rmisev added a commit to rmisev/url that referenced this issue Sep 11, 2017
rmisev added a commit to upa-url/upa that referenced this issue May 24, 2020
rmisev added a commit to upa-url/upa that referenced this issue May 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants