summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej Sobaczewski <msobaczewski@gmail.com>2020-05-07 11:57:53 +0200
committerGitHub <noreply@github.com>2020-05-07 11:57:53 +0200
commit8989300851f6ea65437c7c7a489aa92e3ca6e027 (patch)
treefdc4eb3aa4d49f8e61508117ef61f024f047ceb3
parentaf1ce6c33d65c916894bb8f17544cb80cbe6f902 (diff)
downloadserenity-8989300851f6ea65437c7c7a489aa92e3ca6e027.zip
Browser: Assume http:// when no protocol is provided in the location bar (#2142)
-rw-r--r--Applications/Browser/Tab.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/Applications/Browser/Tab.cpp b/Applications/Browser/Tab.cpp
index fe64cbdae4..dbe4c53b35 100644
--- a/Applications/Browser/Tab.cpp
+++ b/Applications/Browser/Tab.cpp
@@ -30,6 +30,7 @@
#include "History.h"
#include "InspectorWidget.h"
#include "WindowActions.h"
+#include <AK/StringBuilder.h>
#include <LibGUI/Action.h>
#include <LibGUI/Application.h>
#include <LibGUI/BoxLayout.h>
@@ -98,7 +99,15 @@ Tab::Tab()
m_location_box = toolbar.add<GUI::TextBox>();
m_location_box->on_return_pressed = [this] {
- m_html_widget->load(m_location_box->text());
+ String location = m_location_box->text();
+ if (!location.starts_with("file://") && !location.starts_with("http://") && !location.starts_with("https://")) {
+ StringBuilder builder;
+ builder.append("http://");
+ builder.append(location);
+ location = builder.build();
+ }
+
+ m_html_widget->load(location);
};
m_bookmark_button = toolbar.add<GUI::Button>();