mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
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:
parent
ea68bdef26
commit
ffe070d7f9
Notes:
github-actions[bot]
2024-08-05 07:59:07 +00:00
Author: https://github.com/shannonbooth
Commit: ffe070d7f9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/966
5 changed files with 9 additions and 11 deletions
|
@ -148,17 +148,13 @@ bool can_have_its_url_rewritten(DOM::Document const& document, URL::URL const& t
|
|||
|
||||
// 4. If targetURL's scheme is "file", and targetURL and documentURL differ in their path component,
|
||||
// then return false. (Differences in query and fragment are allowed for file: URLs.)
|
||||
// FIXME: Don't create temporary strings to compare paths
|
||||
auto target_url_path = target_url.serialize_path();
|
||||
auto document_url_path = document_url.serialize_path();
|
||||
if (target_url.scheme() == "file"sv
|
||||
&& target_url_path != document_url_path)
|
||||
bool path_components_match = target_url.paths() == document_url.paths();
|
||||
if (target_url.scheme() == "file"sv && !path_components_match)
|
||||
return false;
|
||||
|
||||
// 5. If targetURL and documentURL differ in their path component or query components, then return false.
|
||||
// (Only differences in fragment are allowed for other types of URLs.)
|
||||
if (target_url_path != document_url_path
|
||||
|| target_url.query() != document_url.query())
|
||||
if (!path_components_match || target_url.query() != document_url.query())
|
||||
return false;
|
||||
|
||||
// 6. Return true.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue