AK: Fix bad parsing of some file:/// URLs with base URL

We were dropping the base URL path components in the resulting URL due
to mistakenly determining the input URL to start with a Windows drive
letter. Fix this, add a spec link, and a test.
This commit is contained in:
Andreas Kling 2022-09-20 15:38:53 +02:00
commit 287a9b552a
Notes: sideshowbarker 2024-07-17 06:48:57 +09:00
2 changed files with 16 additions and 1 deletions

View file

@ -84,11 +84,12 @@ static Optional<String> parse_host(StringView input, bool is_not_special = false
return ipv4_host;
}
// https://url.spec.whatwg.org/#start-with-a-windows-drive-letter
constexpr bool starts_with_windows_drive_letter(StringView input)
{
if (input.length() < 2)
return false;
if (!is_ascii_alpha(input[0]) && !(input[1] == ':' || input[1] == '|'))
if (!is_ascii_alpha(input[0]) || !(input[1] == ':' || input[1] == '|'))
return false;
if (input.length() == 2)
return true;