mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-29 04:37:55 +00:00
LibURL: Make URL::serialized_host() infallible
This can no longer fail, so update the return type to match.
This makes a few more methods now unable to return errors, but one thing
at a time. 😅
This commit is contained in:
committed by
Andreas Kling
parent
70c8535b8a
commit
900c131178
@@ -289,10 +289,10 @@ WebIDL::ExceptionOr<String> DOMURL::host() const
|
||||
|
||||
// 3. If url’s port is null, return url’s host, serialized.
|
||||
if (!url.port().has_value())
|
||||
return TRY_OR_THROW_OOM(vm, url.serialized_host());
|
||||
return url.serialized_host();
|
||||
|
||||
// 4. Return url’s host, serialized, followed by U+003A (:) and url’s port, serialized.
|
||||
return TRY_OR_THROW_OOM(vm, String::formatted("{}:{}", TRY_OR_THROW_OOM(vm, url.serialized_host()), *url.port()));
|
||||
return TRY_OR_THROW_OOM(vm, String::formatted("{}:{}", url.serialized_host(), *url.port()));
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-url-hostref-for-dom-url-host%E2%91%A0
|
||||
@@ -309,14 +309,12 @@ void DOMURL::set_host(String const& host)
|
||||
// https://url.spec.whatwg.org/#dom-url-hostname
|
||||
WebIDL::ExceptionOr<String> DOMURL::hostname() const
|
||||
{
|
||||
auto& vm = realm().vm();
|
||||
|
||||
// 1. If this’s URL’s host is null, then return the empty string.
|
||||
if (!m_url.host().has_value())
|
||||
return String {};
|
||||
|
||||
// 2. Return this’s URL’s host, serialized.
|
||||
return TRY_OR_THROW_OOM(vm, m_url.serialized_host());
|
||||
return m_url.serialized_host();
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#ref-for-dom-url-hostname①
|
||||
|
||||
Reference in New Issue
Block a user