From 2905bda0f2333dd36250b2d19d822b0c328305ce Mon Sep 17 00:00:00 2001 From: Diego Iastrubni Date: Thu, 14 Jul 2022 18:32:51 +0300 Subject: [PATCH] Ladybird: Add a protocol to the URL, when one is not set When a http(s):// is not written by the user - lets manually add one. --- Ladybird/Tab.cpp | 4 +++- Ladybird/Tab.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Ladybird/Tab.cpp b/Ladybird/Tab.cpp index b010bbd2d6..28e1a5eed5 100644 --- a/Ladybird/Tab.cpp +++ b/Ladybird/Tab.cpp @@ -73,8 +73,10 @@ Tab::Tab(QMainWindow* window) QObject::connect(focus_location_edit_action, &QAction::triggered, m_location_edit, &QLineEdit::selectAll); } -void Tab::navigate(QString const& url) +void Tab::navigate(QString url) { + if (!url.startsWith("http://", Qt::CaseInsensitive) && !url.startsWith("https://", Qt::CaseInsensitive)) + url = "http://" + url; view().load(url.toUtf8().data()); } diff --git a/Ladybird/Tab.h b/Ladybird/Tab.h index 5ef7e081c8..c9490e63fd 100644 --- a/Ladybird/Tab.h +++ b/Ladybird/Tab.h @@ -23,7 +23,7 @@ public: WebView& view() { return *m_view; } - void navigate(QString const&); + void navigate(QString); void debug_request(String const& request, String const& argument);