summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AK/URL.cpp24
-rw-r--r--AK/URL.h3
-rw-r--r--Tests/AK/TestURL.cpp42
-rw-r--r--Userland/Applications/3DFileViewer/main.cpp2
-rw-r--r--Userland/Applications/Browser/CookieJar.cpp4
-rw-r--r--Userland/Applications/FileManager/FileUtils.cpp9
-rw-r--r--Userland/Applications/FileManager/main.cpp2
-rw-r--r--Userland/Applications/FontEditor/MainWidget.cpp5
-rw-r--r--Userland/Applications/Help/MainWidget.cpp4
-rw-r--r--Userland/Applications/HexEditor/HexEditorWidget.cpp2
-rw-r--r--Userland/Applications/ImageViewer/main.cpp4
-rw-r--r--Userland/Applications/PixelPaint/MainWidget.cpp2
-rw-r--r--Userland/Applications/Presenter/PresenterWidget.cpp2
-rw-r--r--Userland/Applications/Run/RunWindow.cpp5
-rw-r--r--Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp2
-rw-r--r--Userland/Applications/Spreadsheet/HelpWindow.cpp15
-rw-r--r--Userland/Applications/Spreadsheet/Spreadsheet.cpp2
-rw-r--r--Userland/Applications/TextEditor/MainWidget.cpp2
-rw-r--r--Userland/Applications/ThemeEditor/MainWidget.cpp2
-rw-r--r--Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp2
-rw-r--r--Userland/DevTools/HackStudio/Editor.cpp2
-rw-r--r--Userland/DevTools/SQLStudio/MainWidget.cpp2
-rw-r--r--Userland/Libraries/LibGemini/Document.cpp2
-rw-r--r--Userland/Libraries/LibHTTP/HttpRequest.cpp4
-rw-r--r--Userland/Libraries/LibVT/TerminalWidget.cpp6
-rw-r--r--Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Fetch/Request.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/Location.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Loader/FrameLoader.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Loader/Resource.cpp4
-rw-r--r--Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp4
-rw-r--r--Userland/Libraries/LibWeb/URL/URL.cpp2
-rw-r--r--Userland/Libraries/LibWebSocket/ConnectionInfo.cpp5
-rw-r--r--Userland/Services/LaunchServer/Launcher.cpp21
-rw-r--r--Userland/Services/Taskbar/QuickLaunchWidget.cpp5
-rw-r--r--Userland/Utilities/markdown-check.cpp13
-rw-r--r--Userland/Utilities/pro.cpp2
-rw-r--r--Userland/Utilities/xml.cpp31
42 files changed, 131 insertions, 123 deletions
diff --git a/AK/URL.cpp b/AK/URL.cpp
index ec045d9292..0aa17f6c52 100644
--- a/AK/URL.cpp
+++ b/AK/URL.cpp
@@ -27,18 +27,6 @@ URL::URL(StringView string)
}
}
-DeprecatedString URL::path() const
-{
- if (cannot_be_a_base_url())
- return paths()[0];
- StringBuilder builder;
- for (auto& path : m_paths) {
- builder.append('/');
- builder.append(path);
- }
- return builder.to_deprecated_string();
-}
-
URL URL::complete_url(StringView relative_url) const
{
if (!is_valid())
@@ -270,6 +258,18 @@ bool URL::is_special_scheme(StringView scheme)
return scheme.is_one_of("ftp", "file", "http", "https", "ws", "wss");
}
+DeprecatedString URL::serialize_path(ApplyPercentDecoding apply_percent_decoding) const
+{
+ if (cannot_be_a_base_url())
+ return m_paths[0];
+ StringBuilder builder;
+ for (auto& path : m_paths) {
+ builder.append('/');
+ builder.append(apply_percent_decoding == ApplyPercentDecoding::Yes ? percent_decode(path) : path);
+ }
+ return builder.to_deprecated_string();
+}
+
DeprecatedString URL::serialize_data_url() const
{
VERIFY(m_scheme == "data");
diff --git a/AK/URL.h b/AK/URL.h
index 1f18fd9c04..85f2f68042 100644
--- a/AK/URL.h
+++ b/AK/URL.h
@@ -93,8 +93,7 @@ public:
append_path("", ApplyPercentEncoding::No);
}
- DeprecatedString path() const;
-
+ DeprecatedString serialize_path(ApplyPercentDecoding = ApplyPercentDecoding::Yes) const;
DeprecatedString serialize(ExcludeFragment = ExcludeFragment::No) const;
DeprecatedString serialize_for_display() const;
DeprecatedString to_deprecated_string() const { return serialize(); }
diff --git a/Tests/AK/TestURL.cpp b/Tests/AK/TestURL.cpp
index b0e5c453fb..c886b313f1 100644
--- a/Tests/AK/TestURL.cpp
+++ b/Tests/AK/TestURL.cpp
@@ -24,7 +24,7 @@ TEST_CASE(basic)
EXPECT_EQ(url.scheme(), "http");
EXPECT_EQ(url.host(), "www.serenityos.org");
EXPECT_EQ(url.port_or_default(), 80);
- EXPECT_EQ(url.path(), "/");
+ EXPECT_EQ(url.serialize_path(), "/");
EXPECT(url.query().is_null());
EXPECT(url.fragment().is_null());
}
@@ -34,7 +34,7 @@ TEST_CASE(basic)
EXPECT_EQ(url.scheme(), "https");
EXPECT_EQ(url.host(), "www.serenityos.org");
EXPECT_EQ(url.port_or_default(), 443);
- EXPECT_EQ(url.path(), "/index.html");
+ EXPECT_EQ(url.serialize_path(), "/index.html");
EXPECT(url.query().is_null());
EXPECT(url.fragment().is_null());
}
@@ -44,7 +44,7 @@ TEST_CASE(basic)
EXPECT_EQ(url.scheme(), "https");
EXPECT_EQ(url.host(), "localhost");
EXPECT_EQ(url.port_or_default(), 1234);
- EXPECT_EQ(url.path(), "/~anon/test/page.html");
+ EXPECT_EQ(url.serialize_path(), "/~anon/test/page.html");
EXPECT(url.query().is_null());
EXPECT(url.fragment().is_null());
}
@@ -54,7 +54,7 @@ TEST_CASE(basic)
EXPECT_EQ(url.scheme(), "http");
EXPECT_EQ(url.host(), "www.serenityos.org");
EXPECT_EQ(url.port_or_default(), 80);
- EXPECT_EQ(url.path(), "/index.html");
+ EXPECT_EQ(url.serialize_path(), "/index.html");
EXPECT_EQ(url.query(), "");
EXPECT_EQ(url.fragment(), "");
}
@@ -64,7 +64,7 @@ TEST_CASE(basic)
EXPECT_EQ(url.scheme(), "http");
EXPECT_EQ(url.host(), "www.serenityos.org");
EXPECT_EQ(url.port_or_default(), 80);
- EXPECT_EQ(url.path(), "/index.html");
+ EXPECT_EQ(url.serialize_path(), "/index.html");
EXPECT_EQ(url.query(), "foo=1&bar=2");
EXPECT(url.fragment().is_null());
}
@@ -74,7 +74,7 @@ TEST_CASE(basic)
EXPECT_EQ(url.scheme(), "http");
EXPECT_EQ(url.host(), "www.serenityos.org");
EXPECT_EQ(url.port_or_default(), 80);
- EXPECT_EQ(url.path(), "/index.html");
+ EXPECT_EQ(url.serialize_path(), "/index.html");
EXPECT(url.query().is_null());
EXPECT_EQ(url.fragment(), "fragment");
}
@@ -84,7 +84,7 @@ TEST_CASE(basic)
EXPECT_EQ(url.scheme(), "http");
EXPECT_EQ(url.host(), "www.serenityos.org");
EXPECT_EQ(url.port_or_default(), 80);
- EXPECT_EQ(url.path(), "/index.html");
+ EXPECT_EQ(url.serialize_path(), "/index.html");
EXPECT_EQ(url.query(), "foo=1&bar=2&baz=/?");
EXPECT_EQ(url.fragment(), "frag/ment?test#");
}
@@ -120,7 +120,7 @@ TEST_CASE(file_url_with_hostname)
EXPECT_EQ(url.scheme(), "file");
EXPECT_EQ(url.host(), "courage");
EXPECT_EQ(url.port_or_default(), 0);
- EXPECT_EQ(url.path(), "/my/file");
+ EXPECT_EQ(url.serialize_path(), "/my/file");
EXPECT_EQ(url.serialize(), "file://courage/my/file");
EXPECT(url.query().is_null());
EXPECT(url.fragment().is_null());
@@ -132,7 +132,7 @@ TEST_CASE(file_url_with_localhost)
EXPECT(url.is_valid());
EXPECT_EQ(url.scheme(), "file");
EXPECT_EQ(url.host(), "");
- EXPECT_EQ(url.path(), "/my/file");
+ EXPECT_EQ(url.serialize_path(), "/my/file");
EXPECT_EQ(url.serialize(), "file:///my/file");
}
@@ -142,7 +142,7 @@ TEST_CASE(file_url_without_hostname)
EXPECT(url.is_valid());
EXPECT_EQ(url.scheme(), "file");
EXPECT_EQ(url.host(), "");
- EXPECT_EQ(url.path(), "/my/file");
+ EXPECT_EQ(url.serialize_path(), "/my/file");
EXPECT_EQ(url.serialize(), "file:///my/file");
}
@@ -151,7 +151,7 @@ TEST_CASE(file_url_with_encoded_characters)
URL url("file:///my/file/test%23file.txt"sv);
EXPECT(url.is_valid());
EXPECT_EQ(url.scheme(), "file");
- EXPECT_EQ(url.path(), "/my/file/test%23file.txt");
+ EXPECT_EQ(url.serialize_path(), "/my/file/test#file.txt");
EXPECT(url.query().is_null());
EXPECT(url.fragment().is_null());
}
@@ -161,7 +161,7 @@ TEST_CASE(file_url_with_fragment)
URL url("file:///my/file#fragment"sv);
EXPECT(url.is_valid());
EXPECT_EQ(url.scheme(), "file");
- EXPECT_EQ(url.path(), "/my/file");
+ EXPECT_EQ(url.serialize_path(), "/my/file");
EXPECT(url.query().is_null());
EXPECT_EQ(url.fragment(), "fragment");
}
@@ -171,7 +171,7 @@ TEST_CASE(file_url_with_root_path)
URL url("file:///"sv);
EXPECT(url.is_valid());
EXPECT_EQ(url.scheme(), "file");
- EXPECT_EQ(url.path(), "/");
+ EXPECT_EQ(url.serialize_path(), "/");
}
TEST_CASE(file_url_serialization)
@@ -190,7 +190,7 @@ TEST_CASE(about_url)
EXPECT(url.is_valid());
EXPECT_EQ(url.scheme(), "about");
EXPECT(url.host().is_null());
- EXPECT_EQ(url.path(), "blank");
+ EXPECT_EQ(url.serialize_path(), "blank");
EXPECT(url.query().is_null());
EXPECT(url.fragment().is_null());
EXPECT_EQ(url.serialize(), "about:blank");
@@ -333,7 +333,7 @@ TEST_CASE(create_with_file_scheme)
EXPECT_EQ(url.paths()[0], "home");
EXPECT_EQ(url.paths()[1], "anon");
EXPECT_EQ(url.paths()[2], "README.md");
- EXPECT_EQ(url.path(), "/home/anon/README.md");
+ EXPECT_EQ(url.serialize_path(), "/home/anon/README.md");
EXPECT(url.query().is_null());
EXPECT(url.fragment().is_null());
@@ -343,10 +343,10 @@ TEST_CASE(create_with_file_scheme)
EXPECT_EQ(url.paths()[0], "home");
EXPECT_EQ(url.paths()[1], "anon");
EXPECT_EQ(url.paths()[2], "");
- EXPECT_EQ(url.path(), "/home/anon/");
+ EXPECT_EQ(url.serialize_path(), "/home/anon/");
url = URL("file:///home/anon/"sv);
- EXPECT_EQ(url.path(), "/home/anon/");
+ EXPECT_EQ(url.serialize_path(), "/home/anon/");
}
TEST_CASE(complete_url)
@@ -356,7 +356,7 @@ TEST_CASE(complete_url)
EXPECT(url.is_valid());
EXPECT_EQ(url.scheme(), "http");
EXPECT_EQ(url.host(), "serenityos.org");
- EXPECT_EQ(url.path(), "/test.html");
+ EXPECT_EQ(url.serialize_path(), "/test.html");
EXPECT(url.query().is_null());
EXPECT(url.query().is_null());
EXPECT_EQ(url.cannot_be_a_base_url(), false);
@@ -389,7 +389,7 @@ TEST_CASE(unicode)
{
URL url { "http://example.com/_ünicöde_téxt_©"sv };
EXPECT(url.is_valid());
- EXPECT_EQ(url.path(), "/_%C3%BCnic%C3%B6de_t%C3%A9xt_%C2%A9");
+ EXPECT_EQ(url.serialize_path(), "/_ünicöde_téxt_©");
EXPECT(url.query().is_null());
EXPECT(url.fragment().is_null());
}
@@ -398,14 +398,14 @@ TEST_CASE(complete_file_url_with_base)
{
URL url { "file:///home/index.html" };
EXPECT(url.is_valid());
- EXPECT_EQ(url.path(), "/home/index.html");
+ EXPECT_EQ(url.serialize_path(), "/home/index.html");
EXPECT_EQ(url.paths().size(), 2u);
EXPECT_EQ(url.paths()[0], "home");
EXPECT_EQ(url.paths()[1], "index.html");
auto sub_url = url.complete_url("js/app.js"sv);
EXPECT(sub_url.is_valid());
- EXPECT_EQ(sub_url.path(), "/home/js/app.js");
+ EXPECT_EQ(sub_url.serialize_path(), "/home/js/app.js");
}
TEST_CASE(empty_url_with_base_url)
diff --git a/Userland/Applications/3DFileViewer/main.cpp b/Userland/Applications/3DFileViewer/main.cpp
index f1e0f83ac0..59fc2b8e48 100644
--- a/Userland/Applications/3DFileViewer/main.cpp
+++ b/Userland/Applications/3DFileViewer/main.cpp
@@ -146,7 +146,7 @@ void GLContextWidget::drop_event(GUI::DropEvent& event)
if (url.scheme() != "file")
continue;
- auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window(), url.path());
+ auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window(), url.serialize_path());
if (response.is_error())
return;
load_file(response.value().filename(), response.value().release_stream());
diff --git a/Userland/Applications/Browser/CookieJar.cpp b/Userland/Applications/Browser/CookieJar.cpp
index 1ad59b6453..5aacf01361 100644
--- a/Userland/Applications/Browser/CookieJar.cpp
+++ b/Userland/Applications/Browser/CookieJar.cpp
@@ -253,7 +253,7 @@ DeprecatedString CookieJar::default_path(const URL& url)
// https://tools.ietf.org/html/rfc6265#section-5.1.4
// 1. Let uri-path be the path portion of the request-uri if such a portion exists (and empty otherwise).
- DeprecatedString uri_path = url.path();
+ DeprecatedString uri_path = url.serialize_path();
// 2. If the uri-path is empty or if the first character of the uri-path is not a %x2F ("/") character, output %x2F ("/") and skip the remaining steps.
if (uri_path.is_empty() || (uri_path[0] != '/'))
@@ -376,7 +376,7 @@ Vector<Web::Cookie::Cookie> CookieJar::get_matching_cookies(const URL& url, Depr
return;
// The request-uri's path path-matches the cookie's path.
- if (!path_matches(url.path(), cookie.path))
+ if (!path_matches(url.serialize_path(), cookie.path))
return;
// If the cookie's secure-only-flag is true, then the request-uri's scheme must denote a "secure" protocol.
diff --git a/Userland/Applications/FileManager/FileUtils.cpp b/Userland/Applications/FileManager/FileUtils.cpp
index 4e8d4c79aa..17e19ace38 100644
--- a/Userland/Applications/FileManager/FileUtils.cpp
+++ b/Userland/Applications/FileManager/FileUtils.cpp
@@ -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;
}
diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp
index 9a946bcbd4..3724bf9d82 100644
--- a/Userland/Applications/FileManager/main.cpp
+++ b/Userland/Applications/FileManager/main.cpp
@@ -202,7 +202,7 @@ void do_paste(DeprecatedString const& target_directory, GUI::Window* window)
dbgln("Cannot paste URI {}", uri_as_string);
continue;
}
- source_paths.append(url.path());
+ source_paths.append(url.serialize_path());
}
if (!source_paths.is_empty()) {
diff --git a/Userland/Applications/FontEditor/MainWidget.cpp b/Userland/Applications/FontEditor/MainWidget.cpp
index a3dc9d71a7..9c2ef6fe17 100644
--- a/Userland/Applications/FontEditor/MainWidget.cpp
+++ b/Userland/Applications/FontEditor/MainWidget.cpp
@@ -975,8 +975,9 @@ void MainWidget::drop_event(GUI::DropEvent& event)
if (!request_close())
return;
- if (auto result = open_file(urls.first().path()); result.is_error())
- show_error(result.release_error(), "Opening"sv, LexicalPath { urls.first().path() }.basename());
+ auto file_path = urls.first().serialize_path();
+ if (auto result = open_file(file_path); result.is_error())
+ show_error(result.release_error(), "Opening"sv, LexicalPath { file_path }.basename());
}
}
diff --git a/Userland/Applications/Help/MainWidget.cpp b/Userland/Applications/Help/MainWidget.cpp
index 5ff8b23b00..23f4bcb15c 100644
--- a/Userland/Applications/Help/MainWidget.cpp
+++ b/Userland/Applications/Help/MainWidget.cpp
@@ -98,7 +98,7 @@ MainWidget::MainWidget()
m_web_view = find_descendant_of_type_named<WebView::OutOfProcessWebView>("web_view");
m_web_view->on_link_click = [this](auto& url, auto&, unsigned) {
if (url.scheme() == "file") {
- auto path = LexicalPath { url.path() };
+ auto path = LexicalPath { url.serialize_path() };
if (!path.is_child_of(Manual::manual_base_path)) {
open_external(url);
return;
@@ -246,7 +246,7 @@ void MainWidget::open_url(URL const& url)
m_web_view->load(url);
m_web_view->scroll_to_top();
- auto browse_view_index = m_manual_model->index_from_path(url.path());
+ auto browse_view_index = m_manual_model->index_from_path(url.serialize_path());
if (browse_view_index.has_value()) {
if (browse_view_index.value() != m_browse_view->selection_start_index()) {
m_browse_view->expand_all_parents_of(browse_view_index.value());
diff --git a/Userland/Applications/HexEditor/HexEditorWidget.cpp b/Userland/Applications/HexEditor/HexEditorWidget.cpp
index 4d4ef49bd1..653a355c42 100644
--- a/Userland/Applications/HexEditor/HexEditorWidget.cpp
+++ b/Userland/Applications/HexEditor/HexEditorWidget.cpp
@@ -604,7 +604,7 @@ void HexEditorWidget::drop_event(GUI::DropEvent& event)
return;
// TODO: A drop event should be considered user consent for opening a file
- auto response = FileSystemAccessClient::Client::the().request_file(window(), urls.first().path(), Core::File::OpenMode::Read);
+ auto response = FileSystemAccessClient::Client::the().request_file(window(), urls.first().serialize_path(), Core::File::OpenMode::Read);
if (response.is_error())
return;
open_file(response.value().filename(), response.value().release_stream());
diff --git a/Userland/Applications/ImageViewer/main.cpp b/Userland/Applications/ImageViewer/main.cpp
index 2fc6686991..97376771dd 100644
--- a/Userland/Applications/ImageViewer/main.cpp
+++ b/Userland/Applications/ImageViewer/main.cpp
@@ -100,7 +100,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->move_to_front();
- auto path = urls.first().path();
+ auto path = urls.first().serialize_path();
auto result = FileSystemAccessClient::Client::the().request_file_read_only_approved(window, path);
if (result.is_error())
return;
@@ -109,7 +109,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
widget->open_file(value.filename(), value.stream());
for (size_t i = 1; i < urls.size(); ++i) {
- Desktop::Launcher::open(URL::create_with_file_scheme(urls[i].path().characters()), "/bin/ImageViewer");
+ Desktop::Launcher::open(URL::create_with_file_scheme(urls[i].serialize_path().characters()), "/bin/ImageViewer");
}
};
widget->on_doubleclick = [&] {
diff --git a/Userland/Applications/PixelPaint/MainWidget.cpp b/Userland/Applications/PixelPaint/MainWidget.cpp
index f045c84666..9f3b639bfe 100644
--- a/Userland/Applications/PixelPaint/MainWidget.cpp
+++ b/Userland/Applications/PixelPaint/MainWidget.cpp
@@ -1401,7 +1401,7 @@ void MainWidget::drop_event(GUI::DropEvent& event)
if (url.scheme() != "file")
continue;
- auto response = FileSystemAccessClient::Client::the().request_file(window(), url.path(), Core::File::OpenMode::Read);
+ auto response = FileSystemAccessClient::Client::the().request_file(window(), url.serialize_path(), Core::File::OpenMode::Read);
if (response.is_error())
return;
open_image(response.release_value());
diff --git a/Userland/Applications/Presenter/PresenterWidget.cpp b/Userland/Applications/Presenter/PresenterWidget.cpp
index 2620c7d835..92cedb0e9d 100644
--- a/Userland/Applications/Presenter/PresenterWidget.cpp
+++ b/Userland/Applications/Presenter/PresenterWidget.cpp
@@ -214,6 +214,6 @@ void PresenterWidget::drop_event(GUI::DropEvent& event)
return;
window()->move_to_front();
- set_file(urls.first().path());
+ set_file(urls.first().serialize_path());
}
}
diff --git a/Userland/Applications/Run/RunWindow.cpp b/Userland/Applications/Run/RunWindow.cpp
index 0c02bb1600..fa06057f83 100644
--- a/Userland/Applications/Run/RunWindow.cpp
+++ b/Userland/Applications/Run/RunWindow.cpp
@@ -141,9 +141,10 @@ bool RunWindow::run_via_launch(DeprecatedString const& run_input)
auto url = URL::create_with_url_or_path(run_input);
if (url.scheme() == "file") {
- auto real_path_or_error = FileSystem::real_path(url.path());
+ auto file_path = url.serialize_path();
+ auto real_path_or_error = FileSystem::real_path(file_path);
if (real_path_or_error.is_error()) {
- warnln("Failed to launch '{}': {}", url.path(), real_path_or_error.error());
+ warnln("Failed to launch '{}': {}", file_path, real_path_or_error.error());
return false;
}
url = URL::create_with_url_or_path(real_path_or_error.release_value().to_deprecated_string());
diff --git a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp
index aa2d027b09..dad1e03cb9 100644
--- a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp
+++ b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp
@@ -161,7 +161,7 @@ void SoundPlayerWidgetAdvancedView::drop_event(GUI::DropEvent& event)
return;
window()->move_to_front();
// FIXME: Add all paths from drop event to the playlist
- play_file_path(urls.first().path());
+ play_file_path(urls.first().serialize_path());
}
}
diff --git a/Userland/Applications/Spreadsheet/HelpWindow.cpp b/Userland/Applications/Spreadsheet/HelpWindow.cpp
index 168cc6c914..31ce668309 100644
--- a/Userland/Applications/Spreadsheet/HelpWindow.cpp
+++ b/Userland/Applications/Spreadsheet/HelpWindow.cpp
@@ -84,24 +84,25 @@ HelpWindow::HelpWindow(GUI::Window* parent)
m_webview->on_link_click = [this](auto& url, auto&, auto&&) {
VERIFY(url.scheme() == "spreadsheet");
if (url.host() == "example") {
- auto entry = LexicalPath::basename(url.path());
+ auto example_path = url.serialize_path();
+ auto entry = LexicalPath::basename(example_path);
auto doc_option = m_docs.get_object(entry);
if (!doc_option.has_value()) {
- GUI::MessageBox::show_error(this, DeprecatedString::formatted("No documentation entry found for '{}'", url.path()));
+ GUI::MessageBox::show_error(this, DeprecatedString::formatted("No documentation entry found for '{}'", example_path));
return;
}
auto& doc = doc_option.value();
- const auto& name = url.fragment();
+ auto name = url.fragment();
auto maybe_example_data = doc.get_object("example_data"sv);
if (!maybe_example_data.has_value()) {
- GUI::MessageBox::show_error(this, DeprecatedString::formatted("No example data found for '{}'", url.path()));
+ GUI::MessageBox::show_error(this, DeprecatedString::formatted("No example data found for '{}'", example_path));
return;
}
auto& example_data = maybe_example_data.value();
if (!example_data.has_object(name)) {
- GUI::MessageBox::show_error(this, DeprecatedString::formatted("Example '{}' not found for '{}'", name, url.path()));
+ GUI::MessageBox::show_error(this, DeprecatedString::formatted("Example '{}' not found for '{}'", name, example_path));
return;
}
auto& value = example_data.get_object(name).value();
@@ -115,14 +116,14 @@ HelpWindow::HelpWindow(GUI::Window* parent)
auto widget = window->set_main_widget<SpreadsheetWidget>(window, Vector<NonnullRefPtr<Sheet>> {}, false).release_value_but_fixme_should_propagate_errors();
auto sheet = Sheet::from_json(value, widget->workbook());
if (!sheet) {
- GUI::MessageBox::show_error(this, DeprecatedString::formatted("Corrupted example '{}' in '{}'", name, url.path()));
+ GUI::MessageBox::show_error(this, DeprecatedString::formatted("Corrupted example '{}' in '{}'", name, example_path));
return;
}
widget->add_sheet(sheet.release_nonnull());
window->show();
} else if (url.host() == "doc") {
- auto entry = LexicalPath::basename(url.path());
+ auto entry = LexicalPath::basename(url.serialize_path());
m_webview->load(URL::create_with_data("text/html", render(entry)));
} else {
dbgln("Invalid spreadsheet action domain '{}'", url.host());
diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp
index 94e329f367..dc693570f8 100644
--- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp
+++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp
@@ -270,7 +270,7 @@ Optional<Position> Sheet::position_from_url(const URL& url) const
}
// FIXME: Figure out a way to do this cross-process.
- VERIFY(url.path() == DeprecatedString::formatted("/{}", getpid()));
+ VERIFY(url.serialize_path() == DeprecatedString::formatted("/{}", getpid()));
return parse_cell_name(url.fragment());
}
diff --git a/Userland/Applications/TextEditor/MainWidget.cpp b/Userland/Applications/TextEditor/MainWidget.cpp
index 1d317ce531..5b05c6bfcd 100644
--- a/Userland/Applications/TextEditor/MainWidget.cpp
+++ b/Userland/Applications/TextEditor/MainWidget.cpp
@@ -845,7 +845,7 @@ void MainWidget::drop_event(GUI::DropEvent& event)
if (!request_close())
return;
- auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window(), urls.first().path());
+ auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window(), urls.first().serialize_path());
if (response.is_error())
return;
if (auto result = read_file(response.value().filename(), response.value().stream()); result.is_error())
diff --git a/Userland/Applications/ThemeEditor/MainWidget.cpp b/Userland/Applications/ThemeEditor/MainWidget.cpp
index f2a812c9c8..2ca4e5524d 100644
--- a/Userland/Applications/ThemeEditor/MainWidget.cpp
+++ b/Userland/Applications/ThemeEditor/MainWidget.cpp
@@ -671,7 +671,7 @@ void MainWidget::drop_event(GUI::DropEvent& event)
if (request_close() == GUI::Window::CloseRequestDecision::StayOpen)
return;
- auto response = FileSystemAccessClient::Client::the().request_file(window(), urls.first().path(), Core::File::OpenMode::Read);
+ auto response = FileSystemAccessClient::Client::the().request_file(window(), urls.first().serialize_path(), Core::File::OpenMode::Read);
if (response.is_error())
return;
diff --git a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp
index 81df461887..83a40325c6 100644
--- a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp
+++ b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp
@@ -279,7 +279,7 @@ void VideoPlayerWidget::drop_event(GUI::DropEvent& event)
GUI::MessageBox::show_error(window(), "VideoPlayer can only view one clip at a time!"sv);
return;
}
- auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window(), urls.first().path());
+ auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window(), urls.first().serialize_path());
if (response.is_error())
return;
open_file(response.value().filename());
diff --git a/Userland/DevTools/HackStudio/Editor.cpp b/Userland/DevTools/HackStudio/Editor.cpp
index e50bb353a5..c846b340d8 100644
--- a/Userland/DevTools/HackStudio/Editor.cpp
+++ b/Userland/DevTools/HackStudio/Editor.cpp
@@ -384,7 +384,7 @@ void Editor::drop_event(GUI::DropEvent& event)
return;
}
set_current_editor_wrapper(static_cast<EditorWrapper*>(parent()));
- open_file(urls.first().path());
+ open_file(urls.first().serialize_path());
}
}
diff --git a/Userland/DevTools/SQLStudio/MainWidget.cpp b/Userland/DevTools/SQLStudio/MainWidget.cpp
index 39e1e7ea44..d9146f72a3 100644
--- a/Userland/DevTools/SQLStudio/MainWidget.cpp
+++ b/Userland/DevTools/SQLStudio/MainWidget.cpp
@@ -480,7 +480,7 @@ void MainWidget::drop_event(GUI::DropEvent& drop_event)
if (!scheme.equals_ignoring_ascii_case("file"sv))
continue;
- auto lexical_path = LexicalPath(url.path());
+ auto lexical_path = LexicalPath(url.serialize_path());
open_script_from_file(lexical_path);
}
}
diff --git a/Userland/Libraries/LibGemini/Document.cpp b/Userland/Libraries/LibGemini/Document.cpp
index 3f64ea96c8..2e89dc233a 100644
--- a/Userland/Libraries/LibGemini/Document.cpp
+++ b/Userland/Libraries/LibGemini/Document.cpp
@@ -18,7 +18,7 @@ DeprecatedString Document::render_to_html() const
StringBuilder html_builder;
html_builder.append("<!DOCTYPE html>\n<html>\n"sv);
html_builder.append("<head>\n<title>"sv);
- html_builder.append(m_url.path());
+ html_builder.append(m_url.serialize_path());
html_builder.append("</title>\n</head>\n"sv);
html_builder.append("<body>\n"sv);
for (auto& line : m_lines) {
diff --git a/Userland/Libraries/LibHTTP/HttpRequest.cpp b/Userland/Libraries/LibHTTP/HttpRequest.cpp
index cbf3319619..b2ec457f29 100644
--- a/Userland/Libraries/LibHTTP/HttpRequest.cpp
+++ b/Userland/Libraries/LibHTTP/HttpRequest.cpp
@@ -49,9 +49,9 @@ ErrorOr<ByteBuffer> HttpRequest::to_raw_request() const
TRY(builder.try_append(method_name()));
TRY(builder.try_append(' '));
// NOTE: The percent_encode is so that e.g. spaces are properly encoded.
- auto path = m_url.path();
+ auto path = m_url.serialize_path();
VERIFY(!path.is_empty());
- TRY(builder.try_append(URL::percent_encode(m_url.path(), URL::PercentEncodeSet::EncodeURI)));
+ TRY(builder.try_append(URL::percent_encode(path, URL::PercentEncodeSet::EncodeURI)));
if (!m_url.query().is_empty()) {
TRY(builder.try_append('?'));
TRY(builder.try_append(m_url.query()));
diff --git a/Userland/Libraries/LibVT/TerminalWidget.cpp b/Userland/Libraries/LibVT/TerminalWidget.cpp
index 1a0468ab67..23ec4d155b 100644
--- a/Userland/Libraries/LibVT/TerminalWidget.cpp
+++ b/Userland/Libraries/LibVT/TerminalWidget.cpp
@@ -867,7 +867,7 @@ void TerminalWidget::mousemove_event(GUI::MouseEvent& event)
auto handlers = Desktop::Launcher::get_handlers_for_url(attribute.href);
if (!handlers.is_empty()) {
auto url = URL(attribute.href);
- auto path = url.path();
+ auto path = url.serialize_path();
auto app_file = Desktop::AppFile::get_for_app(LexicalPath::basename(handlers[0]));
auto app_name = app_file->is_valid() ? app_file->name() : LexicalPath::basename(handlers[0]);
@@ -1146,7 +1146,7 @@ void TerminalWidget::context_menu_event(GUI::ContextMenuEvent& event)
}));
m_context_menu_for_hyperlink->add_action(GUI::Action::create("Copy &Name", [&](auto&) {
// file://courage/home/anon/something -> /home/anon/something
- auto path = URL(m_context_menu_href).path();
+ auto path = URL(m_context_menu_href).serialize_path();
// /home/anon/something -> something
auto name = LexicalPath::basename(path);
GUI::Clipboard::the().set_plain_text(name);
@@ -1177,7 +1177,7 @@ void TerminalWidget::drop_event(GUI::DropEvent& event)
send_non_user_input(" "sv.bytes());
if (url.scheme() == "file")
- send_non_user_input(url.path().bytes());
+ send_non_user_input(url.serialize_path().bytes());
else
send_non_user_input(url.to_deprecated_string().bytes());
diff --git a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp
index 3cb82cf048..0caffb16b0 100644
--- a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp
+++ b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp
@@ -680,7 +680,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> scheme_fetch(JS::Realm& r
// a body.
// NOTE: URLs such as "about:config" are handled during navigation and result in a network error in the context
// of fetching.
- if (request->current_url().path() == "blank"sv) {
+ if (request->current_url().serialize_path() == "blank"sv) {
auto response = Infrastructure::Response::create(vm);
response->set_status_message(MUST(ByteBuffer::copy("OK"sv.bytes())));
auto header = MUST(Infrastructure::Header::from_string_pair("Content-Type"sv, "text/html;charset=utf-8"sv));
diff --git a/Userland/Libraries/LibWeb/Fetch/Request.cpp b/Userland/Libraries/LibWeb/Fetch/Request.cpp
index 3a894739ff..7a53304df3 100644
--- a/Userland/Libraries/LibWeb/Fetch/Request.cpp
+++ b/Userland/Libraries/LibWeb/Fetch/Request.cpp
@@ -310,7 +310,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::construct_impl(JS::Realm
// - parsedReferrer’s origin is not same origin with origin
// then set request’s referrer to "client".
// FIXME: Actually use the given origin once we have https://url.spec.whatwg.org/#concept-url-origin.
- if ((parsed_referrer.scheme() == "about"sv && parsed_referrer.path() == "client"sv) || !HTML::Origin().is_same_origin(origin)) {
+ if ((parsed_referrer.scheme() == "about"sv && parsed_referrer.serialize_path() == "client"sv) || !HTML::Origin().is_same_origin(origin)) {
request->set_referrer(Infrastructure::Request::Referrer::Client);
}
// 4. Otherwise, set request’s referrer to parsedReferrer.
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
index 53b3aa1f4a..fb7f09953a 100644
--- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
+++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
@@ -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();
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp
index 483515b582..8caf538fe7 100644
--- a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp
+++ b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp
@@ -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();
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.cpp b/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.cpp
index 3ebdf72248..6da33dd473 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.cpp
@@ -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
diff --git a/Userland/Libraries/LibWeb/HTML/Location.cpp b/Userland/Libraries/LibWeb/HTML/Location.cpp
index 0c0247ee4a..21223b1c61 100644
--- a/Userland/Libraries/LibWeb/HTML/Location.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Location.cpp
@@ -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&)
diff --git a/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp b/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp
index 2fcca48565..7ac70edf6b 100644
--- a/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp
+++ b/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp
@@ -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
diff --git a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp
index ff4b9c7554..e1e8cd3a39 100644
--- a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp
+++ b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp
@@ -144,7 +144,7 @@ static bool build_image_document(DOM::Document& document, ByteBuffer const& data
auto title_element = DOM::create_element(document, HTML::TagNames::title, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(head_element->append_child(title_element));
- auto basename = LexicalPath::basename(document.url().path());
+ auto basename = LexicalPath::basename(document.url().serialize_path());
auto title_text = document.heap().allocate<DOM::Text>(document.realm(), document, DeprecatedString::formatted("{} [{}x{}]", basename, bitmap->width(), bitmap->height())).release_allocated_value_but_fixme_should_propagate_errors();
MUST(title_element->append_child(*title_text));
diff --git a/Userland/Libraries/LibWeb/Loader/Resource.cpp b/Userland/Libraries/LibWeb/Loader/Resource.cpp
index 7f6cdcaa1c..71ef8cf9a0 100644
--- a/Userland/Libraries/LibWeb/Loader/Resource.cpp
+++ b/Userland/Libraries/LibWeb/Loader/Resource.cpp
@@ -103,7 +103,7 @@ void Resource::did_load(Badge<ResourceLoader>, ReadonlyBytes data, HashMap<Depre
// FIXME: "The Quite OK Image Format" doesn't have an official mime type yet,
// and servers like nginx will send a generic octet-stream mime type instead.
// Let's use image/x-qoi for now, which is also what our Core::MimeData uses & would guess.
- if (m_mime_type == "application/octet-stream" && url().path().ends_with(".qoi"sv))
+ if (m_mime_type == "application/octet-stream" && url().serialize_path().ends_with(".qoi"sv))
m_mime_type = "image/x-qoi";
} else if (url().scheme() == "data" && !url().data_mime_type().is_empty()) {
dbgln_if(RESOURCE_DEBUG, "This is a data URL with mime-type _{}_", url().data_mime_type());
@@ -113,7 +113,7 @@ void Resource::did_load(Badge<ResourceLoader>, ReadonlyBytes data, HashMap<Depre
if (content_type_options.value_or("").equals_ignoring_ascii_case("nosniff"sv)) {
m_mime_type = "text/plain";
} else {
- m_mime_type = Core::guess_mime_type_based_on_filename(url().path());
+ m_mime_type = Core::guess_mime_type_based_on_filename(url().serialize_path());
}
}
diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp
index fffc0fff11..3c7c8cbdef 100644
--- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp
+++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp
@@ -237,7 +237,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has
if (!m_page.has_value())
return;
- FileRequest file_request(url.path(), [this, success_callback = move(success_callback), error_callback = move(error_callback), log_success, log_failure, request](ErrorOr<i32> file_or_error) {
+ FileRequest file_request(url.serialize_path(), [this, success_callback = move(success_callback), error_callback = move(error_callback), log_success, log_failure, request](ErrorOr<i32> file_or_error) {
--m_pending_loads;
if (on_load_counter_change)
on_load_counter_change();
@@ -275,7 +275,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has
// NOTE: For file:// URLs, we have to guess the MIME type, since there's no HTTP header to tell us what this is.
// We insert a fake Content-Type header here, so that clients can use it to learn the MIME type.
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> response_headers;
- auto mime_type = Core::guess_mime_type_based_on_filename(request.url().path());
+ auto mime_type = Core::guess_mime_type_based_on_filename(request.url().serialize_path());
response_headers.set("Content-Type"sv, mime_type);
success_callback(data, response_headers, {});
diff --git a/Userland/Libraries/LibWeb/URL/URL.cpp b/Userland/Libraries/LibWeb/URL/URL.cpp
index 42d1ea372b..43f58442e1 100644
--- a/Userland/Libraries/LibWeb/URL/URL.cpp
+++ b/Userland/Libraries/LibWeb/URL/URL.cpp
@@ -323,7 +323,7 @@ WebIDL::ExceptionOr<String> URL::pathname() const
auto& vm = realm().vm();
// The pathname getter steps are to return the result of URL path serializing this’s URL.
- return TRY_OR_THROW_OOM(vm, String::from_deprecated_string(m_url.path()));
+ return TRY_OR_THROW_OOM(vm, String::from_deprecated_string(m_url.serialize_path()));
}
// https://url.spec.whatwg.org/#ref-for-dom-url-pathname%E2%91%A0
diff --git a/Userland/Libraries/LibWebSocket/ConnectionInfo.cpp b/Userland/Libraries/LibWebSocket/ConnectionInfo.cpp
index a5846ad2b8..d6bc7036a4 100644
--- a/Userland/Libraries/LibWebSocket/ConnectionInfo.cpp
+++ b/Userland/Libraries/LibWebSocket/ConnectionInfo.cpp
@@ -26,10 +26,11 @@ DeprecatedString ConnectionInfo::resource_name() const
// The "resource-name" can be constructed by concatenating the following:
StringBuilder builder;
// "/" if the path component is empty
- if (m_url.path().is_empty())
+ auto path = m_url.serialize_path();
+ if (path.is_empty())
builder.append('/');
// The path component
- builder.append(m_url.path());
+ builder.append(path);
// "?" if the query component is non-empty
if (!m_url.query().is_empty())
builder.append('?');
diff --git a/Userland/Services/LaunchServer/Launcher.cpp b/Userland/Services/LaunchServer/Launcher.cpp
index b90d59409e..4bb08ea1dc 100644
--- a/Userland/Services/LaunchServer/Launcher.cpp
+++ b/Userland/Services/LaunchServer/Launcher.cpp
@@ -141,7 +141,7 @@ Vector<DeprecatedString> Launcher::handlers_for_url(const URL& url)
{
Vector<DeprecatedString> handlers;
if (url.scheme() == "file") {
- for_each_handler_for_path(url.path(), [&](auto& handler) -> bool {
+ for_each_handler_for_path(url.serialize_path(), [&](auto& handler) -> bool {
handlers.append(handler.executable);
return true;
});
@@ -161,7 +161,7 @@ Vector<DeprecatedString> Launcher::handlers_with_details_for_url(const URL& url)
{
Vector<DeprecatedString> handlers;
if (url.scheme() == "file") {
- for_each_handler_for_path(url.path(), [&](auto& handler) -> bool {
+ for_each_handler_for_path(url.serialize_path(), [&](auto& handler) -> bool {
handlers.append(handler.to_details_str());
return true;
});
@@ -211,7 +211,7 @@ bool Launcher::open_with_handler_name(const URL& url, DeprecatedString const& ha
auto& handler = handler_optional.value();
DeprecatedString argument;
if (url.scheme() == "file")
- argument = url.path();
+ argument = url.serialize_path();
else
argument = url.to_deprecated_string();
return spawn(handler.executable, { argument });
@@ -348,7 +348,8 @@ void Launcher::for_each_handler_for_path(DeprecatedString const& path, Function<
bool Launcher::open_file_url(const URL& url)
{
struct stat st;
- if (stat(url.path().characters(), &st) < 0) {
+ auto file_path = url.serialize_path();
+ if (stat(file_path.characters(), &st) < 0) {
perror("stat");
return false;
}
@@ -356,11 +357,11 @@ bool Launcher::open_file_url(const URL& url)
if (S_ISDIR(st.st_mode)) {
Vector<DeprecatedString> fm_arguments;
if (url.fragment().is_empty()) {
- fm_arguments.append(url.path());
+ fm_arguments.append(file_path);
} else {
fm_arguments.append("-s");
fm_arguments.append("-r");
- fm_arguments.append(DeprecatedString::formatted("{}/{}", url.path(), url.fragment()));
+ fm_arguments.append(DeprecatedString::formatted("{}/{}", file_path, url.fragment()));
}
auto handler_optional = m_file_handlers.get("directory");
@@ -372,10 +373,10 @@ bool Launcher::open_file_url(const URL& url)
}
if ((st.st_mode & S_IFMT) == S_IFREG && st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
- return spawn(url.path(), {});
+ return spawn(file_path, {});
- auto extension = LexicalPath::extension(url.path()).to_lowercase();
- auto mime_type = mime_type_for_file(url.path());
+ auto extension = LexicalPath::extension(file_path).to_lowercase();
+ auto mime_type = mime_type_for_file(file_path);
auto mime_type_or_extension = extension;
bool should_use_mime_type = mime_type.has_value() && has_mime_handlers(mime_type.value());
@@ -389,7 +390,7 @@ bool Launcher::open_file_url(const URL& url)
// Additional parameters parsing, specific for the file protocol and txt file handlers
Vector<DeprecatedString> additional_parameters;
- DeprecatedString filepath = url.path();
+ DeprecatedString filepath = url.serialize_path();
auto parameters = url.query().split('&');
for (auto const& parameter : parameters) {
diff --git a/Userland/Services/Taskbar/QuickLaunchWidget.cpp b/Userland/Services/Taskbar/QuickLaunchWidget.cpp
index ae9235d312..fb331fc4ab 100644
--- a/Userland/Services/Taskbar/QuickLaunchWidget.cpp
+++ b/Userland/Services/Taskbar/QuickLaunchWidget.cpp
@@ -243,13 +243,14 @@ void QuickLaunchWidget::drop_event(GUI::DropEvent& event)
if (event.mime_data().has_urls()) {
auto urls = event.mime_data().urls();
for (auto& url : urls) {
- auto entry = QuickLaunchEntry::create_from_path(url.path());
+ auto path = url.serialize_path();
+ auto entry = QuickLaunchEntry::create_from_path(path);
if (entry) {
auto item_name = sanitize_entry_name(entry->name());
auto result = add_or_adjust_button(item_name, entry.release_nonnull());
if (result.is_error())
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to add quick launch entry: {}", result.release_error()));
- Config::write_string("Taskbar"sv, quick_launch, item_name, url.path());
+ Config::write_string("Taskbar"sv, quick_launch, item_name, path);
}
}
}
diff --git a/Userland/Utilities/markdown-check.cpp b/Userland/Utilities/markdown-check.cpp
index 47db678beb..5e6e22e99d 100644
--- a/Userland/Utilities/markdown-check.cpp
+++ b/Userland/Utilities/markdown-check.cpp
@@ -192,29 +192,30 @@ RecursionDecision MarkdownLinkage::visit(Markdown::Text::LinkNode const& link_no
m_has_invalid_link = true;
return RecursionDecision::Recurse;
}
- if (url.paths().size() < 2) {
+ if (url.path_segment_count() < 2) {
warnln("help://man URL is missing section or page: {}", href);
m_has_invalid_link = true;
return RecursionDecision::Recurse;
}
// Remove leading '/' from the path.
- auto file = DeprecatedString::formatted("{}/Base/usr/share/man/man{}.md", m_serenity_source_directory, url.path().substring(1));
+ auto file = DeprecatedString::formatted("{}/Base/usr/share/man/man{}.md", m_serenity_source_directory, url.serialize_path().substring(1));
m_file_links.append({ file, DeprecatedString(), StringCollector::from(*link_node.text) });
return RecursionDecision::Recurse;
}
if (url.scheme() == "file") {
- if (url.path().contains("man"sv) && url.path().ends_with(".md"sv)) {
+ auto file_path = url.serialize_path();
+ if (file_path.contains("man"sv) && file_path.ends_with(".md"sv)) {
warnln("Inter-manpage link without the help:// scheme: {}\nPlease use help URLs of the form 'help://man/<section>/<subsection...>/<page>'", href);
m_has_invalid_link = true;
return RecursionDecision::Recurse;
}
// TODO: Check more possible links other than icons.
- if (url.path().starts_with("/res/icons/"sv)) {
- auto file = DeprecatedString::formatted("{}/Base{}", m_serenity_source_directory, url.path());
+ if (file_path.starts_with("/res/icons/"sv)) {
+ auto file = DeprecatedString::formatted("{}/Base{}", m_serenity_source_directory, file_path);
m_file_links.append({ file, DeprecatedString(), StringCollector::from(*link_node.text) });
- } else if (url.path().starts_with("/bin"sv)) {
+ } else if (file_path.starts_with("/bin"sv)) {
StringBuilder builder;
link_node.text->render_to_html(builder);
auto link_text = builder.string_view();
diff --git a/Userland/Utilities/pro.cpp b/Userland/Utilities/pro.cpp
index 41d20e9789..157ea98f1c 100644
--- a/Userland/Utilities/pro.cpp
+++ b/Userland/Utilities/pro.cpp
@@ -324,7 +324,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
if (output_name.is_empty())
- output_name = url.path();
+ output_name = url.serialize_path();
LexicalPath path { output_name };
output_name = path.basename();
diff --git a/Userland/Utilities/xml.cpp b/Userland/Utilities/xml.cpp
index 40c0316b77..65fb0d4aa0 100644
--- a/Userland/Utilities/xml.cpp
+++ b/Userland/Utilities/xml.cpp
@@ -371,7 +371,7 @@ static auto parse(StringView contents)
if (url.scheme() != "file")
return Error::from_string_literal("NYI: Nonlocal entity");
- auto file = TRY(Core::File::open(url.path(), Core::File::OpenMode::Read));
+ auto file = TRY(Core::File::open(url.serialize_path(), Core::File::OpenMode::Read));
return DeprecatedString::copy(TRY(file->read_until_eof()));
},
},
@@ -440,28 +440,29 @@ static void do_run_tests(XML::Document& document)
continue;
}
- auto file_result = Core::File::open(url.path(), Core::File::OpenMode::Read);
+ auto file_path = url.serialize_path();
+ auto file_result = Core::File::open(file_path, Core::File::OpenMode::Read);
if (file_result.is_error()) {
- warnln("Read error for {}: {}", url.path(), file_result.error());
- s_test_results.set(url.path(), TestResult::RunnerFailed);
+ warnln("Read error for {}: {}", file_path, file_result.error());
+ s_test_results.set(file_path, TestResult::RunnerFailed);
continue;
}
- warnln("Running test {}", url.path());
+ warnln("Running test {}", file_path);
auto contents = file_result.value()->read_until_eof();
if (contents.is_error()) {
- warnln("Read error for {}: {}", url.path(), contents.error());
- s_test_results.set(url.path(), TestResult::RunnerFailed);
+ warnln("Read error for {}: {}", file_path, contents.error());
+ s_test_results.set(file_path, TestResult::RunnerFailed);
continue;
}
auto parser = parse(contents.value());
auto doc_or_error = parser.parse();
if (doc_or_error.is_error()) {
if (type == "invalid" || type == "error" || type == "not-wf")
- s_test_results.set(url.path(), TestResult::Passed);
+ s_test_results.set(file_path, TestResult::Passed);
else
- s_test_results.set(url.path(), TestResult::Failed);
+ s_test_results.set(file_path, TestResult::Failed);
continue;
}
@@ -471,33 +472,33 @@ static void do_run_tests(XML::Document& document)
auto file_result = Core::File::open(out_path, Core::File::OpenMode::Read);
if (file_result.is_error()) {
warnln("Read error for {}: {}", out_path, file_result.error());
- s_test_results.set(url.path(), TestResult::RunnerFailed);
+ s_test_results.set(file_path, TestResult::RunnerFailed);
continue;
}
auto contents = file_result.value()->read_until_eof();
if (contents.is_error()) {
warnln("Read error for {}: {}", out_path, contents.error());
- s_test_results.set(url.path(), TestResult::RunnerFailed);
+ s_test_results.set(file_path, TestResult::RunnerFailed);
continue;
}
auto parser = parse(contents.value());
auto out_doc_or_error = parser.parse();
if (out_doc_or_error.is_error()) {
warnln("Parse error for {}: {}", out_path, out_doc_or_error.error());
- s_test_results.set(url.path(), TestResult::RunnerFailed);
+ s_test_results.set(file_path, TestResult::RunnerFailed);
continue;
}
auto out_doc = out_doc_or_error.release_value();
if (out_doc.root() != doc_or_error.value().root()) {
- s_test_results.set(url.path(), TestResult::Failed);
+ s_test_results.set(file_path, TestResult::Failed);
continue;
}
}
if (type == "invalid" || type == "error" || type == "not-wf")
- s_test_results.set(url.path(), TestResult::Failed);
+ s_test_results.set(file_path, TestResult::Failed);
else
- s_test_results.set(url.path(), TestResult::Passed);
+ s_test_results.set(file_path, TestResult::Passed);
}
}
}