LibURL: Clarify whether an Origin is opaque

Origins are immutable and we know on construction whether an Origin is
opaque. This also removes an implicit reliance on Host's Empty state.
This commit is contained in:
Sam Atkins 2024-11-27 14:16:31 +00:00 committed by Andreas Kling
commit 8b984c0c57
Notes: github-actions[bot] 2024-11-30 11:24:16 +00:00
4 changed files with 40 additions and 19 deletions

View file

@ -42,13 +42,15 @@ namespace AK {
unsigned Traits<URL::Origin>::hash(URL::Origin const& origin)
{
if (origin.is_opaque())
return 0;
unsigned hash = origin.scheme().hash();
if (origin.port().has_value())
hash = pair_int_hash(hash, *origin.port());
if (!origin.host().has<Empty>())
hash = pair_int_hash(hash, URL::Parser::serialize_host(origin.host()).release_value_but_fixme_should_propagate_errors().hash());
hash = pair_int_hash(hash, URL::Parser::serialize_host(origin.host()).release_value_but_fixme_should_propagate_errors().hash());
return hash;
}