1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 01:07:44 +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:
Shannon Booth 2023-07-27 21:40:41 +12:00 committed by Andreas Kling
parent 768f070b86
commit 8751be09f9
36 changed files with 175 additions and 143 deletions

View file

@ -191,7 +191,7 @@ RecursionDecision MarkdownLinkage::visit(Markdown::Text::LinkNode const& link_no
return RecursionDecision::Recurse;
}
if (url.scheme() == "help") {
if (url.host() != "man") {
if (url.host() != String::from_utf8_short_string("man"sv)) {
warnln("help:// URL without 'man': {}", href);
m_has_invalid_link = true;
return RecursionDecision::Recurse;

View file

@ -343,7 +343,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (output_name.is_empty() || output_name == "/") {
int i = -1;
do {
output_name = url.host();
output_name = url.serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string();
if (i > -1)
output_name = DeprecatedString::formatted("{}.{}", output_name, i);
++i;