1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:24:57 +00:00

AK+Everywhere: Replace URL::paths() with path_segment_at_index()

This allows accessing and looping over the path segments in a URL
without necessarily allocating a new vector if you want them percent
decoded too (which path_segment_at_index() has an option for).
This commit is contained in:
MacDue 2023-04-13 23:29:51 +01:00 committed by Andreas Kling
parent 35612c6a7f
commit 5db1eb9961
6 changed files with 28 additions and 21 deletions

View file

@ -536,7 +536,7 @@ URL URLParser::parse(StringView raw_input, Optional<URL> const& base_url, Option
url->m_query = {};
auto substring_from_pointer = input.substring_view(iterator - input.begin()).as_string();
if (!starts_with_windows_drive_letter(substring_from_pointer)) {
if (!url->paths().is_empty() && !(url->scheme() == "file" && url->paths().size() == 1 && is_normalized_windows_drive_letter(url->paths()[0])))
if (!url->m_paths.is_empty() && !(url->scheme() == "file" && url->m_paths.size() == 1 && is_normalized_windows_drive_letter(url->m_paths[0])))
url->m_paths.remove(url->m_paths.size() - 1);
} else {
report_validation_error();