mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:07:34 +00:00
AK+Everywhere: Change URL::path() to serialize_path()
This now defaults to serializing the path with percent decoded segments (which is what all callers expect), but has an option not to. This fixes `file://` URLs with spaces in their paths. The name has been changed to serialize_path() path to make it more clear that this method will generate a new string each call (except for the cannot_be_a_base_url() case). A few callers have then been updated to avoid repeatedly calling this function.
This commit is contained in:
parent
5acd40c525
commit
35612c6a7f
42 changed files with 131 additions and 123 deletions
|
@ -39,7 +39,7 @@ static bool url_matches_about_blank(AK::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.path() == "blank"sv
|
||||
&& url.serialize_path() == "blank"sv
|
||||
&& url.username().is_empty()
|
||||
&& url.password().is_empty()
|
||||
&& url.host().is_null();
|
||||
|
|
|
@ -121,7 +121,7 @@ static bool url_matches_about_blank(AK::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.path() == "blank"sv
|
||||
&& url.serialize_path() == "blank"sv
|
||||
&& url.username().is_empty()
|
||||
&& url.password().is_empty()
|
||||
&& url.host().is_null();
|
||||
|
|
|
@ -293,7 +293,7 @@ DeprecatedString HTMLHyperlinkElementUtils::pathname() const
|
|||
// 4. If url's cannot-be-a-base-URL is true, then return url's path[0].
|
||||
// 5. If url's path is empty, then return the empty string.
|
||||
// 6. Return "/", followed by the strings in url's path (including empty strings), separated from each other by "/".
|
||||
return m_url->path();
|
||||
return m_url->serialize_path();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/links.html#dom-hyperlink-pathname
|
||||
|
|
|
@ -233,7 +233,7 @@ WebIDL::ExceptionOr<String> Location::pathname() const
|
|||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
|
||||
|
||||
// 2. Return the result of URL path serializing this Location object's url.
|
||||
return TRY_OR_THROW_OOM(vm, String::from_deprecated_string(url().path()));
|
||||
return TRY_OR_THROW_OOM(vm, String::from_deprecated_string(url().serialize_path()));
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> Location::set_pathname(String const&)
|
||||
|
|
|
@ -92,7 +92,7 @@ WebIDL::ExceptionOr<String> WorkerLocation::pathname() const
|
|||
{
|
||||
auto& vm = realm().vm();
|
||||
// The pathname getter steps are to return the result of URL path serializing this's WorkerGlobalScope object's url.
|
||||
return TRY_OR_THROW_OOM(vm, String::from_deprecated_string(m_global_scope->url().path()));
|
||||
return TRY_OR_THROW_OOM(vm, String::from_deprecated_string(m_global_scope->url().serialize_path()));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/workers.html#dom-workerlocation-search
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue