mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 18:47:44 +00:00
headless-browser: Massage URLs a bit before loading
This is to mimic what Ladybird and Browser do before trying to load the URL.
This commit is contained in:
parent
4420e48dc3
commit
31bdd8a918
1 changed files with 11 additions and 1 deletions
|
@ -15,6 +15,7 @@
|
||||||
#include <AK/DeprecatedString.h>
|
#include <AK/DeprecatedString.h>
|
||||||
#include <AK/LexicalPath.h>
|
#include <AK/LexicalPath.h>
|
||||||
#include <AK/NonnullOwnPtr.h>
|
#include <AK/NonnullOwnPtr.h>
|
||||||
|
#include <AK/String.h>
|
||||||
#include <AK/URL.h>
|
#include <AK/URL.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
|
@ -159,6 +160,15 @@ static ErrorOr<NonnullRefPtr<Core::Timer>> load_page_for_screenshot_and_exit(Cor
|
||||||
return timer;
|
return timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ErrorOr<URL> format_url(StringView url)
|
||||||
|
{
|
||||||
|
URL formatted_url { url };
|
||||||
|
if (!formatted_url.is_valid())
|
||||||
|
formatted_url = TRY(String::formatted("http://{}", url));
|
||||||
|
|
||||||
|
return formatted_url;
|
||||||
|
}
|
||||||
|
|
||||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
#if !defined(AK_OS_SERENITY)
|
#if !defined(AK_OS_SERENITY)
|
||||||
|
@ -193,7 +203,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
static constexpr Gfx::IntSize window_size { 800, 600 };
|
static constexpr Gfx::IntSize window_size { 800, 600 };
|
||||||
|
|
||||||
auto view = TRY(HeadlessWebContentView::create(move(theme), window_size, web_driver_ipc_path));
|
auto view = TRY(HeadlessWebContentView::create(move(theme), window_size, web_driver_ipc_path));
|
||||||
view->load(URL { url });
|
view->load(TRY(format_url(url)));
|
||||||
|
|
||||||
RefPtr<Core::Timer> timer;
|
RefPtr<Core::Timer> timer;
|
||||||
if (web_driver_ipc_path.is_empty())
|
if (web_driver_ipc_path.is_empty())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue