LibWeb+LibURL: Use URL paths directly for comparison

This matches the text of the spec a little more closely in many cases
and is also more efficient than serializing the URL path.
This commit is contained in:
Shannon Booth 2024-08-05 15:14:00 +12:00 committed by Andreas Kling
commit ffe070d7f9
Notes: github-actions[bot] 2024-08-05 07:59:07 +00:00
5 changed files with 9 additions and 11 deletions

View file

@ -40,7 +40,7 @@ bool url_matches_about_blank(URL::URL const& url)
{
// A URL matches about:blank if its scheme is "about", its path contains a single string "blank", its username and password are the empty string, and its host is null.
return url.scheme() == "about"sv
&& url.serialize_path() == "blank"sv
&& url.paths().size() == 1 && url.paths()[0] == "blank"sv
&& url.username().is_empty()
&& url.password().is_empty()
&& url.host().has<Empty>();
@ -51,7 +51,7 @@ bool url_matches_about_srcdoc(URL::URL const& url)
{
// A URL matches about:srcdoc if its scheme is "about", its path contains a single string "srcdoc", its query is null, its username and password are the empty string, and its host is null.
return url.scheme() == "about"sv
&& url.serialize_path() == "srcdoc"sv
&& url.paths().size() == 1 && url.paths()[0] == "srcdoc"sv
&& !url.query().has_value()
&& url.username().is_empty()
&& url.password().is_empty()