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
parent 3124dca528
commit 8b984c0c57
4 changed files with 40 additions and 19 deletions

View File

@@ -119,9 +119,14 @@ ErrorOr<void> encode(Encoder& encoder, URL::URL const& value)
template<>
ErrorOr<void> encode(Encoder& encoder, URL::Origin const& origin)
{
TRY(encoder.encode<ByteString>(origin.scheme()));
TRY(encoder.encode(origin.host()));
TRY(encoder.encode(origin.port()));
if (origin.is_opaque()) {
TRY(encoder.encode(true));
} else {
TRY(encoder.encode(false));
TRY(encoder.encode<ByteString>(origin.scheme()));
TRY(encoder.encode(origin.host()));
TRY(encoder.encode(origin.port()));
}
return {};
}