diff options
author | Linus Groh <mail@linusgroh.de> | 2020-10-08 21:23:04 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-10-08 23:20:52 +0200 |
commit | 4ef3a55900d4b274175f56fdfdcf9ad9b84c1edc (patch) | |
tree | 3d0896838f5e74d1e2a1099eb2d00bc4c679b5e7 /Userland | |
parent | f6af2d747e236e938f0015ba2a0b4a968f9f8dd1 (diff) | |
download | serenity-4ef3a55900d4b274175f56fdfdcf9ad9b84c1edc.zip |
html: Create URL from filename, if any
This makes it possible for the WebView to resolve relative paths in
documents loaded from a file.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/html.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Userland/html.cpp b/Userland/html.cpp index 34b5339102..a72de4bcde 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<Web::InProcessWebView>(); - 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 |