mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 22:38:51 +00:00
AK: Serialize URL hosts with 'concept-host-serializer'
In order to follow spec text to achieve this, we need to change the underlying representation of a host in AK::URL to deserialized format. Before this, we were parsing the host and then immediately serializing it again. Making that change resulted in a whole bunch of fallout. After this change, callers can access the serialized data through this concept-host-serializer. The functional end result of this change is that IPv6 hosts are now correctly serialized to be surrounded with '[' and ']'.
This commit is contained in:
parent
768f070b86
commit
8751be09f9
Notes:
sideshowbarker
2024-07-18 02:13:10 +09:00
Author: https://github.com/shannonbooth
Commit: 8751be09f9
Pull-request: https://github.com/SerenityOS/serenity/pull/20245
Reviewed-by: https://github.com/kennethmyhra ✅
36 changed files with 175 additions and 143 deletions
|
@ -167,15 +167,15 @@ DeprecatedString HTMLHyperlinkElementUtils::host() const
|
|||
auto& url = m_url;
|
||||
|
||||
// 3. If url or url's host is null, return the empty string.
|
||||
if (!url.has_value() || url->host().is_null())
|
||||
if (!url.has_value() || url->host().has<Empty>())
|
||||
return DeprecatedString::empty();
|
||||
|
||||
// 4. If url's port is null, return url's host, serialized.
|
||||
if (!url->port().has_value())
|
||||
return url->host();
|
||||
return url->serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string();
|
||||
|
||||
// 5. Return url's host, serialized, followed by ":" and url's port, serialized.
|
||||
return DeprecatedString::formatted("{}:{}", url->host(), url->port().value());
|
||||
return DeprecatedString::formatted("{}:{}", url->serialized_host().release_value_but_fixme_should_propagate_errors(), url->port().value());
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/links.html#dom-hyperlink-host
|
||||
|
@ -205,11 +205,14 @@ DeprecatedString HTMLHyperlinkElementUtils::hostname() const
|
|||
// 1. Reinitialize url.
|
||||
//
|
||||
// 2. Let url be this element's url.
|
||||
//
|
||||
AK::URL url(href());
|
||||
|
||||
// 3. If url or url's host is null, return the empty string.
|
||||
//
|
||||
if (url.host().has<Empty>())
|
||||
return DeprecatedString::empty();
|
||||
|
||||
// 4. Return url's host, serialized.
|
||||
return AK::URL(href()).host();
|
||||
return url.serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string();
|
||||
}
|
||||
|
||||
void HTMLHyperlinkElementUtils::set_hostname(DeprecatedString hostname)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue