Re: [whatwg/url] Should file URLs have opaque hostnames? (#599)

Node.js's [url.pathToFileURL](https://nodejs.org/api/url.html#url_url_pathtofileurl_path) function, when run on Windows, calls domainToASCII on the provided NetBIOS machine name, which would return the empty string if the NetBIOS name has a space. That's probably not the correct behavior, though no one seems to have complained so far.

Would someone be able to test the Windows [UrlCreateFromPath](https://docs.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-urlcreatefrompatha) function? I'd be curious to know how it treats `\\some computer\foo\bar.txt`.

[RFC 8089](https://datatracker.ietf.org/doc/html/rfc8089) provides some useful background information on file URLs, but unfortunately doesn't consider the question of weird characters in hostname or IDNs. RFC 8089 uses the grammar in [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2) to describe file hosts though, and the `reg-name` production does not allow spaces to exist but does allow percent-encoded bytes.

I'd be inclined to allow some sort of opaque hostnames for file URLs as they already have a lot of exceptions in the spec, and hostname in file URLs is basically a legacy feature to support Windows anyway.

-- 
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/599#issuecomment-842587528

Received on Monday, 17 May 2021 19:51:45 UTC