mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Update URLParser.{cpp,h} to use east const
This commit is contained in:
parent
0f8ed6183b
commit
44937e2dfc
Notes:
sideshowbarker
2024-07-18 16:52:12 +09:00
Author: https://github.com/MaxWipfli Commit: https://github.com/SerenityOS/serenity/commit/44937e2dfc2 Pull-request: https://github.com/SerenityOS/serenity/pull/7791 Reviewed-by: https://github.com/awesomekling
2 changed files with 13 additions and 13 deletions
|
@ -22,12 +22,12 @@ constexpr bool is_url_code_point(u32 code_point)
|
|||
return is_ascii_alphanumeric(code_point) || code_point >= 0xA0 || "!$&'()*+,-./:;=?@_~"sv.contains(code_point);
|
||||
}
|
||||
|
||||
static void report_validation_error(const SourceLocation& location = SourceLocation::current())
|
||||
static void report_validation_error(SourceLocation const& location = SourceLocation::current())
|
||||
{
|
||||
dbgln_if(URL_PARSER_DEBUG, "URLParser::parse: Validation error! {}", location);
|
||||
}
|
||||
|
||||
static Optional<String> parse_opaque_host(const StringView& input)
|
||||
static Optional<String> parse_opaque_host(StringView const& input)
|
||||
{
|
||||
auto forbidden_host_code_points_excluding_percent = "\0\t\n\r #/:<>?@[\\]^|"sv;
|
||||
for (auto code_point : forbidden_host_code_points_excluding_percent) {
|
||||
|
@ -41,7 +41,7 @@ static Optional<String> parse_opaque_host(const StringView& input)
|
|||
return URL::percent_encode(input, URL::PercentEncodeSet::C0Control);
|
||||
}
|
||||
|
||||
static Optional<String> parse_ipv4_address(const StringView& input)
|
||||
static Optional<String> parse_ipv4_address(StringView const& input)
|
||||
{
|
||||
// FIXME: Implement the correct IPv4 parser as specified by https://url.spec.whatwg.org/#concept-ipv4-parser.
|
||||
return input;
|
||||
|
@ -49,7 +49,7 @@ static Optional<String> parse_ipv4_address(const StringView& input)
|
|||
|
||||
// https://url.spec.whatwg.org/#concept-host-parser
|
||||
// NOTE: This is a very bare-bones implementation.
|
||||
static Optional<String> parse_host(const StringView& input, bool is_not_special = false)
|
||||
static Optional<String> parse_host(StringView const& input, bool is_not_special = false)
|
||||
{
|
||||
if (input.starts_with('[')) {
|
||||
if (!input.ends_with(']')) {
|
||||
|
@ -81,7 +81,7 @@ static Optional<String> parse_host(const StringView& input, bool is_not_special
|
|||
return ipv4_host;
|
||||
}
|
||||
|
||||
constexpr bool starts_with_windows_drive_letter(const StringView& input)
|
||||
constexpr bool starts_with_windows_drive_letter(StringView const& input)
|
||||
{
|
||||
if (input.length() < 2)
|
||||
return false;
|
||||
|
@ -92,29 +92,29 @@ constexpr bool starts_with_windows_drive_letter(const StringView& input)
|
|||
return "/\\?#"sv.contains(input[2]);
|
||||
}
|
||||
|
||||
constexpr bool is_windows_drive_letter(const StringView& input)
|
||||
constexpr bool is_windows_drive_letter(StringView const& input)
|
||||
{
|
||||
return input.length() == 2 && is_ascii_alpha(input[0]) && (input[1] == ':' || input[1] == '|');
|
||||
}
|
||||
|
||||
constexpr bool is_normalized_windows_drive_letter(const StringView& input)
|
||||
constexpr bool is_normalized_windows_drive_letter(StringView const& input)
|
||||
{
|
||||
return input.length() == 2 && is_ascii_alpha(input[0]) && input[1] == ':';
|
||||
}
|
||||
|
||||
constexpr bool is_single_dot_path_segment(const StringView& input)
|
||||
constexpr bool is_single_dot_path_segment(StringView const& input)
|
||||
{
|
||||
return input == "."sv || input.equals_ignoring_case("%2e"sv);
|
||||
}
|
||||
|
||||
constexpr bool is_double_dot_path_segment(const StringView& input)
|
||||
constexpr bool is_double_dot_path_segment(StringView const& input)
|
||||
{
|
||||
return input == ".."sv || input.equals_ignoring_case(".%2e"sv) || input.equals_ignoring_case("%2e."sv) || input.equals_ignoring_case("%2e%2e"sv);
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#data-urls
|
||||
// FIXME: This only loosely follow the spec, as we use the same class for "regular" and data URLs, unlike the spec.
|
||||
Optional<URL> URLParser::parse_data_url(const StringView& raw_input)
|
||||
Optional<URL> URLParser::parse_data_url(StringView const& raw_input)
|
||||
{
|
||||
dbgln_if(URL_PARSER_DEBUG, "URLParser::parse_data_url: Parsing '{}'.", raw_input);
|
||||
VERIFY(raw_input.starts_with("data:"));
|
||||
|
@ -154,7 +154,7 @@ Optional<URL> URLParser::parse_data_url(const StringView& raw_input)
|
|||
// NOTE: Since the URL class's member variables contain percent decoded data, we have to deviate from the URL parser specification when setting
|
||||
// some of those values. Because the specification leaves all values percent encoded in their URL data structure, we have to percent decode
|
||||
// everything before setting the member variables.
|
||||
URL URLParser::parse(Badge<URL>, const StringView& raw_input, URL const* base_url)
|
||||
URL URLParser::parse(Badge<URL>, StringView const& raw_input, URL const* base_url)
|
||||
{
|
||||
dbgln_if(URL_PARSER_DEBUG, "URLParser::parse: Parsing '{}'", raw_input);
|
||||
if (raw_input.is_empty())
|
||||
|
|
|
@ -38,10 +38,10 @@ public:
|
|||
Fragment
|
||||
};
|
||||
|
||||
static URL parse(Badge<URL>, const StringView& input, const URL* base_url = nullptr);
|
||||
static URL parse(Badge<URL>, StringView const& input, URL const* base_url = nullptr);
|
||||
|
||||
private:
|
||||
static Optional<URL> parse_data_url(const StringView& raw_input);
|
||||
static Optional<URL> parse_data_url(StringView const& raw_input);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue