-
Notifications
You must be signed in to change notification settings - Fork 141
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
Why is the host dropped if the path contains a Windows drive letter? #302
Comments
What does Edge do? And just to be clear, you mean that on Windows |
@edge keeps the host, but throws an Invalid URL Error upon serializing with So it doesn't really follow the spec either, but if they changed it to support this it wouldn't be a breaking change. There is no indication why it would not be a valid location, and why it would be valid for remote Unix machines but not for remote Windows machines. Imagine you have an application running on machine A that identifies files by file URIs (e.g. an editor), then passes these in some way to another server or container B (e.g. a language intelligence server). For the external server, the files are not on |
Well if Windows doesn't support it I don't think it necessarily makes sense to generate such URLs since these are all special cases for Windows. How did you run into this? |
Shouldn't the spec decide what implementations support, not the support decide what is specced? The way I ran into it is actually the example I gave above. I was refactoring a language server to use the WHATWG |
Not when it comes to legacy features, really. |
How is this legacy though? |
I've run into this. I think it is more clean to confine the deviant normalization rules of drive letters to the path only. What is the motivation for dropping the host? |
I don't recall. I think I'd probably take a PR that changes this, but I'm not actively working on URL issues myself for a bit. |
Per https://jsdom.github.io/whatwg-url/#url=ZmlsZTovL3NvbWVob3N0L0M6L3Rlc3Qv&base=YWJvdXQ6Ymxhbms= it seems both Chrome and Safari preserve the host, even on macOS. I think that means we should change this. |
Hmm, on Windows I see Chrome giving the same results as the URL Standard. |
Yeah, I'm trying to make sense of why that is. It's supposed to be the same on all platforms but I haven't figured out where the host is getting stripped yet Edit: Found it - special Windows-only logic that nukes the host |
I tried finding rationale in https://code.google.com/archive/p/google-url/source/default/commits but not successful thus far. Not sure what we want to do here now. |
Do we know what historic IE did? Much of the files behavior is trying to match IE5.5/IE6 URL parsing quirks. By nature of the feature, and the behavior on other Chrome platforms, I feel like we can say this is a Chrome Windows-ism to support Enterprises. If IE changed behavior, it makes a compelling argument that Enterprises don’t need this and it should be “easy” to remove. If IE matches the current behavior, we can still pursue removing, but would probably need metrics in place to measure how often this happens (and potentially the host being localhost or . as special cases) to evaluate removing the Windows-specific behavior. |
I tested IE6 (and Chrome 49) on XP using BrowserStack via Live DOM Viewer (one of the few pages that still works, hurray) with <a href="file://test/d:/testtest;'?"></a>
<script>
w(document.getElementsByTagName("a")[0].href)
</script> as my input and verified that (In "real" Edge 18 input such as file://aa/d:/bb yields file://aad:/bb (indeed, d: eats a prior slash). Microsoft clearly didn't have a lot of regression tests for this.) |
I have made a bunch of screenshots with browserstack (initially for #405) and transcribed from them the results that are relevant to this issue. The results may also be relevant to #515. The following applies only to file URLs. Observations:
Browser Tests:
|
The
file:
URL scheme does not define that the URL cannot have a host:https://en.wikipedia.org/wiki/File_URI_scheme
It looks like the spec says in https://url.spec.whatwg.org/#path-state 1.4.1.1 that a host is to be dropped if the path contains a Windows drive letter:
This means it's impossible to have a Windows file URL have a different host than the empty string:
This can be seen in jsdom/whatwg-url. Chrome actually behaves differently and keeps the host. NodeJS 7's bundled URL implementation also keeps the host.
but it is possible with a Unix-style file URL. Is there any reason for this?
It should be possible to refer to a file on a remote Windows machine just like on a remote Unix machine.
The text was updated successfully, but these errors were encountered: