[whatwg/url] Why is the host dropped if the path contains a Windows drive letter? (#302)

The `file:` URL scheme does not define that the URL cannot have a host:

> A file URI takes the form of
>     file://host/path
> where host is the fully qualified domain name of the system on which the path is accessible, and path is a hierarchical directory path of the form directory/directory/.../name. If host is omitted, it is taken to be "localhost", the machine from which the URL is being interpreted.

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:

> - If url’s scheme is "file", url’s path is empty, and buffer is a Windows drive letter, then:
>   - If url’s host is neither the empty string nor null, validation error, set url’s host to the empty string.

This means it's impossible to have a Windows file URL have a different host than the empty string:

```js
const uri = new URL('file://host/foo')
uri.host // 'host'
uri.pathname = '/c:/bar'
uri.host // ''

new URL('/c:/baz/qux', 'file://host/foo/bar').href
"file:///c:/baz/qux"
```

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.


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/302

Received on Friday, 28 April 2017 07:37:21 UTC