1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:57:45 +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:
MacDue 2023-04-14 20:12:03 +01:00 committed by Andreas Kling
parent 5acd40c525
commit 35612c6a7f
42 changed files with 131 additions and 123 deletions

View file

@ -129,13 +129,14 @@ ErrorOr<bool> handle_drop(GUI::DropEvent const& event, DeprecatedString const& d
Vector<DeprecatedString> paths_to_copy;
for (auto& url_to_copy : urls) {
if (!url_to_copy.is_valid() || url_to_copy.path() == target)
auto file_path = url_to_copy.serialize_path();
if (!url_to_copy.is_valid() || file_path == target)
continue;
auto new_path = DeprecatedString::formatted("{}/{}", target, LexicalPath::basename(url_to_copy.path()));
if (url_to_copy.path() == new_path)
auto new_path = DeprecatedString::formatted("{}/{}", target, LexicalPath::basename(file_path));
if (file_path == new_path)
continue;
paths_to_copy.append(url_to_copy.path());
paths_to_copy.append(file_path);
has_accepted_drop = true;
}