diff --git a/AK/URLParser.cpp b/AK/URLParser.cpp index be02312cf0e..06e3723b187 100644 --- a/AK/URLParser.cpp +++ b/AK/URLParser.cpp @@ -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 parse_opaque_host(const StringView& input) +static Optional 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 parse_opaque_host(const StringView& input) return URL::percent_encode(input, URL::PercentEncodeSet::C0Control); } -static Optional parse_ipv4_address(const StringView& input) +static Optional 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 parse_ipv4_address(const StringView& input) // https://url.spec.whatwg.org/#concept-host-parser // NOTE: This is a very bare-bones implementation. -static Optional parse_host(const StringView& input, bool is_not_special = false) +static Optional parse_host(StringView const& input, bool is_not_special = false) { if (input.starts_with('[')) { if (!input.ends_with(']')) { @@ -81,7 +81,7 @@ static Optional 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 URLParser::parse_data_url(const StringView& raw_input) +Optional 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 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, const StringView& raw_input, URL const* base_url) +URL URLParser::parse(Badge, StringView const& raw_input, URL const* base_url) { dbgln_if(URL_PARSER_DEBUG, "URLParser::parse: Parsing '{}'", raw_input); if (raw_input.is_empty()) diff --git a/AK/URLParser.h b/AK/URLParser.h index c27bad7e40d..ea403751d0f 100644 --- a/AK/URLParser.h +++ b/AK/URLParser.h @@ -38,10 +38,10 @@ public: Fragment }; - static URL parse(Badge, const StringView& input, const URL* base_url = nullptr); + static URL parse(Badge, StringView const& input, URL const* base_url = nullptr); private: - static Optional parse_data_url(const StringView& raw_input); + static Optional parse_data_url(StringView const& raw_input); }; }