Re: [whatwg/url] Preserve "localhost" in file URLs? (#618)

I realize that Chromium's solution is going to be a bit tricky to implement in the Standard, given the way the parser is set up currently. We would have to make two additions:

* in the [path state](https://url.spec.whatwg.org/#path-state): to check whether the host is `localhost` and strip it if needed
* counterintuitively, also in the [host state](https://url.spec.whatwg.org/#host-state): to check whether the _path_ starts with the drive letter

The path state addition takes care of the parsing-from-scratch case as well as `u.pathname = 'C:/abc'`. The host state addition is needed for `u.host = 'localhost'` on a URL that already has a Windows drive letter.

----

Related to this, I've really starting to prefer separate parsing and canonicalizing stages, rather than putting everything in a single parser algorithm. That architecture not only simplifies implementing this change, but also makes proving roundtrippability easier (it's easier to show that canonicalization is idempotent).

-- 
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/618#issuecomment-951176675

Received on Monday, 25 October 2021 18:10:55 UTC