mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-02 17:28:48 +00:00
AK+LibURL: Move AK::URL into a new URL library
This URL library ends up being a relatively fundamental base library of the system, as LibCore depends on LibURL. This change has two main benefits: * Moving AK back more towards being an agnostic library that can be used between the kernel and userspace. URL has never really fit that description - and is not used in the kernel. * URL _should_ depend on LibUnicode, as it needs punnycode support. However, it's not really possible to do this inside of AK as it can't depend on any external library. This change brings us a little closer to being able to do that, but unfortunately we aren't there quite yet, as the code generators depend on LibCore.
This commit is contained in:
parent
21bfa001b1
commit
e800605ad3
Notes:
sideshowbarker
2024-07-17 04:41:05 +09:00
Author: https://github.com/shannonbooth
Commit: e800605ad3
Pull-request: https://github.com/SerenityOS/serenity/pull/23443
Issue: https://github.com/SerenityOS/serenity/issues/22884
Reviewed-by: https://github.com/trflynn89
403 changed files with 1336 additions and 1305 deletions
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/URLParser.h>
|
||||
#include <LibURL/Parser.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/HTMLHyperlinkElementUtils.h>
|
||||
#include <LibWeb/HTML/Navigable.h>
|
||||
|
@ -78,7 +78,7 @@ void HTMLHyperlinkElementUtils::set_protocol(StringView protocol)
|
|||
return;
|
||||
|
||||
// 3. Basic URL parse the given value, followed by ":", with this element's url as url and scheme start state as state override.
|
||||
auto result_url = URLParser::basic_parse(MUST(String::formatted("{}:", protocol)), {}, m_url, URLParser::State::SchemeStart);
|
||||
auto result_url = URL::Parser::basic_parse(MUST(String::formatted("{}:", protocol)), {}, m_url, URL::Parser::State::SchemeStart);
|
||||
if (result_url.is_valid())
|
||||
m_url = move(result_url);
|
||||
|
||||
|
@ -192,7 +192,7 @@ void HTMLHyperlinkElementUtils::set_host(StringView host)
|
|||
return;
|
||||
|
||||
// 4. Basic URL parse the given value, with url as url and host state as state override.
|
||||
auto result_url = URLParser::basic_parse(host, {}, url, URLParser::State::Host);
|
||||
auto result_url = URL::Parser::basic_parse(host, {}, url, URL::Parser::State::Host);
|
||||
if (result_url.is_valid())
|
||||
m_url = move(result_url);
|
||||
|
||||
|
@ -205,7 +205,7 @@ String HTMLHyperlinkElementUtils::hostname() const
|
|||
// 1. Reinitialize url.
|
||||
//
|
||||
// 2. Let url be this element's url.
|
||||
URL url(href());
|
||||
URL::URL url(href());
|
||||
|
||||
// 3. If url or url's host is null, return the empty string.
|
||||
if (url.host().has<Empty>())
|
||||
|
@ -228,7 +228,7 @@ void HTMLHyperlinkElementUtils::set_hostname(StringView hostname)
|
|||
return;
|
||||
|
||||
// 4. Basic URL parse the given value, with url as url and hostname state as state override.
|
||||
auto result_url = URLParser::basic_parse(hostname, {}, m_url, URLParser::State::Hostname);
|
||||
auto result_url = URL::Parser::basic_parse(hostname, {}, m_url, URL::Parser::State::Hostname);
|
||||
if (result_url.is_valid())
|
||||
m_url = move(result_url);
|
||||
|
||||
|
@ -270,7 +270,7 @@ void HTMLHyperlinkElementUtils::set_port(StringView port)
|
|||
m_url->set_port({});
|
||||
} else {
|
||||
// 5. Otherwise, basic URL parse the given value, with url as url and port state as state override.
|
||||
auto result_url = URLParser::basic_parse(port, {}, m_url, URLParser::State::Port);
|
||||
auto result_url = URL::Parser::basic_parse(port, {}, m_url, URL::Parser::State::Port);
|
||||
if (result_url.is_valid())
|
||||
m_url = move(result_url);
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ void HTMLHyperlinkElementUtils::set_pathname(StringView pathname)
|
|||
url->set_paths({});
|
||||
|
||||
// 5. Basic URL parse the given value, with url as url and path start state as state override.
|
||||
auto result_url = URLParser::basic_parse(pathname, {}, move(url), URLParser::State::PathStart);
|
||||
auto result_url = URL::Parser::basic_parse(pathname, {}, move(url), URL::Parser::State::PathStart);
|
||||
if (result_url.is_valid())
|
||||
m_url = move(result_url);
|
||||
|
||||
|
@ -361,7 +361,7 @@ void HTMLHyperlinkElementUtils::set_search(StringView search)
|
|||
url_copy->set_query(String {});
|
||||
|
||||
// 3. Basic URL parse input, with null, this element's node document's document's character encoding, url as url, and query state as state override.
|
||||
auto result_url = URLParser::basic_parse(input, {}, move(url_copy), URLParser::State::Query);
|
||||
auto result_url = URL::Parser::basic_parse(input, {}, move(url_copy), URL::Parser::State::Query);
|
||||
if (result_url.is_valid())
|
||||
m_url = move(result_url);
|
||||
}
|
||||
|
@ -409,7 +409,7 @@ void HTMLHyperlinkElementUtils::set_hash(StringView hash)
|
|||
url_copy->set_fragment(String {});
|
||||
|
||||
// 3. Basic URL parse input, with url as url and fragment state as state override.
|
||||
auto result_url = URLParser::basic_parse(input, {}, move(url_copy), URLParser::State::Fragment);
|
||||
auto result_url = URL::Parser::basic_parse(input, {}, move(url_copy), URL::Parser::State::Fragment);
|
||||
if (result_url.is_valid())
|
||||
m_url = move(result_url);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue