diff --git a/AK/URL.cpp b/AK/URL.cpp index ec045d92929..0aa17f6c522 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 1f18fd9c047..85f2f680427 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 b0e5c453fb8..c886b313f1a 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 f1e0f83ac0f..59fc2b8e48c 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 1ad59b64533..5aacf013618 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 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 4e8d4c79aa6..17e19ace383 100644 --- a/Userland/Applications/FileManager/FileUtils.cpp +++ b/Userland/Applications/FileManager/FileUtils.cpp @@ -129,13 +129,14 @@ ErrorOr handle_drop(GUI::DropEvent const& event, DeprecatedString const& d Vector 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 9a946bcbd41..3724bf9d823 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 a3dc9d71a7d..9c2ef6fe173 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 5ff8b23b00a..23f4bcb15cc 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("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 4d4ef49bd1f..653a355c427 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 2fc66869915..97376771dd9 100644 --- a/Userland/Applications/ImageViewer/main.cpp +++ b/Userland/Applications/ImageViewer/main.cpp @@ -100,7 +100,7 @@ ErrorOr 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 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 f045c846661..9f3b639bfe6 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 2620c7d835e..92cedb0e9d7 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 0c02bb1600a..fa06057f834 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 aa2d027b098..dad1e03cb9d 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 168cc6c914b..31ce6683098 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(window, Vector> {}, 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 94e329f3673..dc693570f88 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp +++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp @@ -270,7 +270,7 @@ Optional 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 1d317ce531e..5b05c6bfcde 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 f2a812c9c84..2ca4e5524d6 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 81df461887d..83a40325c63 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 e50bb353a5f..c846b340d89 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(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 39e1e7ea448..d9146f72a33 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 3f64ea96c80..2e89dc233a0 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("\n\n"sv); html_builder.append("\n"sv); - html_builder.append(m_url.path()); + html_builder.append(m_url.serialize_path()); html_builder.append("\n\n"sv); html_builder.append("\n"sv); for (auto& line : m_lines) { diff --git a/Userland/Libraries/LibHTTP/HttpRequest.cpp b/Userland/Libraries/LibHTTP/HttpRequest.cpp index cbf33196196..b2ec457f297 100644 --- a/Userland/Libraries/LibHTTP/HttpRequest.cpp +++ b/Userland/Libraries/LibHTTP/HttpRequest.cpp @@ -49,9 +49,9 @@ ErrorOr 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 1a0468ab678..23ec4d155b1 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 3cb82cf0483..0caffb16b06 100644 --- a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp @@ -680,7 +680,7 @@ WebIDL::ExceptionOr> 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 3a894739ffe..7a53304df37 100644 --- a/Userland/Libraries/LibWeb/Fetch/Request.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Request.cpp @@ -310,7 +310,7 @@ WebIDL::ExceptionOr> 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 53b3aa1f4ab..fb7f09953a5 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 483515b5823..8caf538fe78 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 3ebdf72248b..6da33dd473b 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 0c0247ee4ac..21223b1c61b 100644 --- a/Userland/Libraries/LibWeb/HTML/Location.cpp +++ b/Userland/Libraries/LibWeb/HTML/Location.cpp @@ -233,7 +233,7 @@ WebIDL::ExceptionOr 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 Location::set_pathname(String const&) diff --git a/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp b/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp index 2fcca48565b..7ac70edf6b3 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp +++ b/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp @@ -92,7 +92,7 @@ WebIDL::ExceptionOr 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 ff4b9c75547..e1e8cd3a39f 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(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 7f6cdcaa1c0..71ef8cf9a0f 100644 --- a/Userland/Libraries/LibWeb/Loader/Resource.cpp +++ b/Userland/Libraries/LibWeb/Loader/Resource.cpp @@ -103,7 +103,7 @@ void Resource::did_load(Badge, ReadonlyBytes data, HashMap, ReadonlyBytes data, HashMap 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 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 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 42d1ea372b7..43f58442e1e 100644 --- a/Userland/Libraries/LibWeb/URL/URL.cpp +++ b/Userland/Libraries/LibWeb/URL/URL.cpp @@ -323,7 +323,7 @@ WebIDL::ExceptionOr 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 a5846ad2b87..d6bc7036a40 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 b90d59409e7..4bb08ea1dc4 100644 --- a/Userland/Services/LaunchServer/Launcher.cpp +++ b/Userland/Services/LaunchServer/Launcher.cpp @@ -141,7 +141,7 @@ Vector Launcher::handlers_for_url(const URL& url) { Vector 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 Launcher::handlers_with_details_for_url(const URL& url) { Vector 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 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 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 ae9235d312f..fb331fc4abc 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 47db678beb2..5e6e22e99d5 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/
//'", 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 41d20e97898..157ea98f1cd 100644 --- a/Userland/Utilities/pro.cpp +++ b/Userland/Utilities/pro.cpp @@ -324,7 +324,7 @@ ErrorOr 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 40c0316b777..65fb0d4aa05 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); } } }