From b1e4f701735c707c5b45716bd479605f44b6af49 Mon Sep 17 00:00:00 2001 From: FalseHonesty Date: Fri, 22 May 2020 21:24:58 -0400 Subject: [PATCH] AK: Fix URL::complete_url behaviour for when a fragment is passed Previously, passing a fragment string ("#section3") to the complete_url method would result in a URL that looked like "file:///home/anon/www/#section3" which was obviously incorrect. Now the result looks like "file:///home/anon/www/afrag.html#section3". --- AK/URL.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/AK/URL.cpp b/AK/URL.cpp index d8acf57c36..f9bd26aa5e 100644 --- a/AK/URL.cpp +++ b/AK/URL.cpp @@ -307,6 +307,12 @@ URL URL::complete_url(const String& string) const return url; } + if (string.starts_with("#")) { + url = *this; + url.set_fragment(string.substring(1, string.length() - 1)); + return url; + } + StringBuilder builder; FileSystemPath fspath(path()); builder.append('/');