From 4ef3a55900d4b274175f56fdfdcf9ad9b84c1edc Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Thu, 8 Oct 2020 21:23:04 +0100 Subject: [PATCH] html: Create URL from filename, if any This makes it possible for the WebView to resolve relative paths in documents loaded from a file. --- Userland/html.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Userland/html.cpp b/Userland/html.cpp index 34b53391026..a72de4bcdeb 100644 --- a/Userland/html.cpp +++ b/Userland/html.cpp @@ -40,10 +40,12 @@ int main(int argc, char** argv) auto app = GUI::Application::construct(argc, argv); auto f = Core::File::construct(); + URL url; bool success; if (argc < 2) { success = f->open(STDIN_FILENO, Core::IODevice::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescription::No); } else { + url = URL::create_with_file_protocol(argv[1]); f->set_filename(argv[1]); success = f->open(Core::IODevice::OpenMode::ReadOnly); } @@ -56,7 +58,7 @@ int main(int argc, char** argv) auto window = GUI::Window::construct(); auto& widget = window->set_main_widget(); - widget.load_html(html, URL()); + widget.load_html(html, url); if (!widget.document()->title().is_null()) window->set_title(String::format("%s - HTML", widget.document()->title().characters())); else