1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 19:37:34 +00:00

AK: Rename URLParser::parse to URLParser::basic_parse

To make it more clear that this function implements
'concept-basic-url-parser' instead of 'concept-url-parser'.
This commit is contained in:
Shannon Booth 2023-07-15 14:29:20 +12:00 committed by Andreas Kling
parent 6fecd8cc44
commit 5625ca5cb9
8 changed files with 29 additions and 28 deletions

View file

@ -15,9 +15,9 @@
namespace AK {
// FIXME: It could make sense to force users of URL to use URLParser::parse() explicitly instead of using a constructor.
// FIXME: It could make sense to force users of URL to use URLParser::basic_parse() explicitly instead of using a constructor.
URL::URL(StringView string)
: URL(URLParser::parse(string))
: URL(URLParser::basic_parse(string))
{
if constexpr (URL_PARSER_DEBUG) {
if (m_valid)
@ -32,7 +32,7 @@ URL URL::complete_url(StringView relative_url) const
if (!is_valid())
return {};
return URLParser::parse(relative_url, *this);
return URLParser::basic_parse(relative_url, *this);
}
DeprecatedString URL::username(ApplyPercentDecoding apply_percent_decoding) const

View file

@ -27,7 +27,7 @@ static bool is_url_code_point(u32 code_point)
static void report_validation_error(SourceLocation const& location = SourceLocation::current())
{
dbgln_if(URL_PARSER_DEBUG, "URLParser::parse: Validation error! {}", location);
dbgln_if(URL_PARSER_DEBUG, "URLParser::basic_parse: Validation error! {}", location);
}
static Optional<DeprecatedString> parse_opaque_host(StringView input)
@ -194,7 +194,7 @@ Optional<URL> URLParser::parse_data_url(StringView raw_input)
// future for validation of URLs, which would then lead to infinite recursion.
// The same goes for base_url, because e.g. the port() getter does not always return m_port, and we are interested in the underlying member
// variables' values here, not what the URL class presents to its users.
URL URLParser::parse(StringView raw_input, Optional<URL> const& base_url, Optional<URL> url, Optional<State> state_override)
URL URLParser::basic_parse(StringView raw_input, Optional<URL> const& base_url, Optional<URL> url, Optional<State> state_override)
{
dbgln_if(URL_PARSER_DEBUG, "URLParser::parse: Parsing '{}'", raw_input);
if (raw_input.is_empty())
@ -287,11 +287,11 @@ URL URLParser::parse(StringView raw_input, Optional<URL> const& base_url, Option
if constexpr (URL_PARSER_DEBUG) {
if (code_point == end_of_file)
dbgln("URLParser::parse: {} state with EOF.", state_name(state));
dbgln("URLParser::basic_parse: {} state with EOF.", state_name(state));
else if (is_ascii_printable(code_point))
dbgln("URLParser::parse: {} state with code point U+{:04X} ({:c}).", state_name(state), code_point, code_point);
dbgln("URLParser::basic_parse: {} state with code point U+{:04X} ({:c}).", state_name(state), code_point, code_point);
else
dbgln("URLParser::parse: {} state with code point U+{:04X}.", state_name(state), code_point);
dbgln("URLParser::basic_parse: {} state with code point U+{:04X}.", state_name(state), code_point);
}
switch (state) {

View file

@ -55,7 +55,8 @@ public:
VERIFY_NOT_REACHED();
}
static URL parse(StringView input, Optional<URL> const& base_url = {}, Optional<URL> url = {}, Optional<State> state_override = {});
// https://url.spec.whatwg.org/#concept-basic-url-parser
static URL basic_parse(StringView input, Optional<URL> const& base_url = {}, Optional<URL> url = {}, Optional<State> state_override = {});
// https://url.spec.whatwg.org/#string-percent-encode-after-encoding
static DeprecatedString percent_encode_after_encoding(StringView input, URL::PercentEncodeSet percent_encode_set, bool space_as_plus = false);