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".
This commit is contained in:
FalseHonesty 2020-05-22 21:24:58 -04:00 committed by Andreas Kling
parent 2e4147d0fc
commit b1e4f70173
Notes: sideshowbarker 2024-07-19 06:13:42 +09:00

View file

@ -307,6 +307,12 @@ URL URL::complete_url(const String& string) const
return url; return url;
} }
if (string.starts_with("#")) {
url = *this;
url.set_fragment(string.substring(1, string.length() - 1));
return url;
}
StringBuilder builder; StringBuilder builder;
FileSystemPath fspath(path()); FileSystemPath fspath(path());
builder.append('/'); builder.append('/');