Re: [whatwg/url] The opaque host parser allows the empty string, contradicting opaque hosts being "non-empty ASCII string[s]" (Issue #908)

Scripter17 left a comment (whatwg/url#908)

As far as I can tell, the only thing required to make calling the opaque host parser equivalent to the normal parser with opaque = true (and rejecting IPv6 hosts) is to add the non-empty check to it. It already rejects IPv6 hosts per [ and ] being forbidden host codepoints.

For what it's worth, in my personal "better URL" library, I expose an OpaqueHost type that uses the opaque host parser directly, but just adds the "can't be empty" stipulation. It seems a bit silly to me to have that canonically (though not necessarily literally) have to take a detour through the normal host parser.

Whether or not I canonically take that detour has no effect on the code at all since regardless of if the IPv6 host parser succeeds or fails it'd return an InvalidOpaqueHost error, but I don't see any particular need to block off the more direct route.

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

Message ID: <whatwg/url/issues/908/4483288855@github.com>

Received on Tuesday, 19 May 2026 00:05:08 UTC