LibURL: Replace Host's Empty state with making Url's Host optional

A couple of reasons:
- Origin's Host (when in the tuple state) can't be null
- There's an "empty host" concept in the spec which is NOT the same as a
  null Host, and that was confusing me.
This commit is contained in:
Sam Atkins 2024-11-27 12:48:28 +00:00 committed by Andreas Kling
commit 90e763de4c
Notes: github-actions[bot] 2024-11-30 11:24:09 +00:00
17 changed files with 44 additions and 42 deletions

View file

@ -284,7 +284,7 @@ WebIDL::ExceptionOr<String> DOMURL::host() const
auto& url = m_url;
// 2. If urls host is null, then return the empty string.
if (url.host().has<Empty>())
if (!url.host().has_value())
return String {};
// 3. If urls port is null, return urls host, serialized.
@ -312,7 +312,7 @@ WebIDL::ExceptionOr<String> DOMURL::hostname() const
auto& vm = realm().vm();
// 1. If thiss URLs host is null, then return the empty string.
if (m_url.host().has<Empty>())
if (!m_url.host().has_value())
return String {};
// 2. Return thiss URLs host, serialized.
@ -477,6 +477,7 @@ void DOMURL::set_hash(String const& hash)
}
// https://url.spec.whatwg.org/#concept-domain
// FIXME: Move into URL::Host
bool host_is_domain(URL::Host const& host)
{
// A domain is a non-empty ASCII string that identifies a realm within a network.