1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:28:11 +00:00

html: Create URL from filename, if any

This makes it possible for the WebView to resolve relative paths in
documents loaded from a file.
This commit is contained in:
Linus Groh 2020-10-08 21:23:04 +01:00 committed by Andreas Kling
parent f6af2d747e
commit 4ef3a55900

View file

@ -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