1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-05 22:14:55 +00:00

AK: Directly append URL paths where applicable

This is a little closer to the spec text, and helps us avoid using
the ApplyPercentEncoding flag.
This commit is contained in:
Shannon Booth 2023-08-06 16:13:08 +12:00 committed by Andreas Kling
parent fc44d09221
commit c4d7be100e
2 changed files with 3 additions and 4 deletions

View File

@ -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;

View File

@ -1359,7 +1359,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional<URL> 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 bases path[0] is a normalized Windows drive letter, then append bases path[0] to urls 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<URL> const& base_url,
buffer.append(':');
}
// 2. Append buffer to urls 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.