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

@ -310,7 +310,8 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::construct_impl(JS::Realm
// - parsedReferrers origin is not same origin with origin
// then set requests referrer to "client".
auto parsed_referrer_origin = DOMURL::url_origin(parsed_referrer);
if ((parsed_referrer.scheme() == "about"sv && parsed_referrer.serialize_path() == "client"sv) || !parsed_referrer_origin.is_same_origin(origin)) {
if ((parsed_referrer.scheme() == "about"sv && parsed_referrer.paths().size() == 1 && parsed_referrer.paths()[0] == "client"sv)
|| !parsed_referrer_origin.is_same_origin(origin)) {
request->set_referrer(Infrastructure::Request::Referrer::Client);
}
// 4. Otherwise, set requests referrer to parsedReferrer.