LibURL: Promote Host to a proper class

This lets us move a few Host-related functions (like serialization and
checks for what the Host is) into Host instead of having them dotted
around the codebase.

For now, the interface is still very Variant-like, to avoid having to
change quite so much in one go.
This commit is contained in:
Sam Atkins
2024-11-27 15:12:17 +00:00
committed by Andreas Kling
parent 90e763de4c
commit 63688148b9
14 changed files with 212 additions and 134 deletions

View File

@@ -24,7 +24,7 @@ String Origin::serialize() const
result.append("://"sv);
// 4. Append origin's host, serialized, to result.
result.append(MUST(Parser::serialize_host(host())));
result.append(host().serialize());
// 5. If origin's port is non-null, append a U+003A COLON character (:), and origin's port, serialized, to result.
if (port().has_value()) {
@@ -50,7 +50,7 @@ unsigned Traits<URL::Origin>::hash(URL::Origin const& origin)
if (origin.port().has_value())
hash = pair_int_hash(hash, *origin.port());
hash = pair_int_hash(hash, URL::Parser::serialize_host(origin.host()).release_value_but_fixme_should_propagate_errors().hash());
hash = pair_int_hash(hash, origin.host().serialize().hash());
return hash;
}