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:
parent
f6af2d747e
commit
4ef3a55900
1 changed files with 3 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue