From c4d7be100e4f1cec82a3426c3f3d5c2912182205 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sun, 6 Aug 2023 16:13:08 +1200 Subject: [PATCH] AK: Directly append URL paths where applicable This is a little closer to the spec text, and helps us avoid using the ApplyPercentEncoding flag. --- AK/URL.h | 2 +- AK/URLParser.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/AK/URL.h b/AK/URL.h index 56729ab883..bcda75b7d4 100644 --- a/AK/URL.h +++ b/AK/URL.h @@ -112,7 +112,7 @@ public: void append_slash() { // NOTE: To indicate that we want to end the path with a slash, we have to append an empty path segment. - append_path("", ApplyPercentEncoding::No); + m_paths.append(""); } DeprecatedString serialize_path(ApplyPercentDecoding = ApplyPercentDecoding::Yes) const; diff --git a/AK/URLParser.cpp b/AK/URLParser.cpp index ef0d2245f9..5d05979347 100644 --- a/AK/URLParser.cpp +++ b/AK/URLParser.cpp @@ -1359,7 +1359,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional const& base_url, // 2. If the code point substring from pointer to the end of input does not start with a Windows drive letter and base’s path[0] is a normalized Windows drive letter, then append base’s path[0] to url’s path. auto substring_from_pointer = input.substring_view(iterator - input.begin()).as_string(); if (!starts_with_windows_drive_letter(substring_from_pointer) && is_normalized_windows_drive_letter(base_url->m_paths[0])) - url->append_path(base_url->m_paths[0], URL::ApplyPercentEncoding::No); + url->m_paths.append(base_url->m_paths[0]); } // 2. Set state to path state, and decrease pointer by 1. @@ -1499,8 +1499,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional const& base_url, buffer.append(':'); } // 2. Append buffer to url’s path. - // FIXME: It would be nicer (and closer to spec) if URLParser could just directly append the path. - url->append_path(buffer.string_view(), URL::ApplyPercentEncoding::No); + url->m_paths.append(buffer.string_view()); } // 5. Set buffer to the empty string.