diff options
author | Maciej Sobaczewski <msobaczewski@gmail.com> | 2020-05-07 11:57:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-07 11:57:53 +0200 |
commit | 8989300851f6ea65437c7c7a489aa92e3ca6e027 (patch) | |
tree | fdc4eb3aa4d49f8e61508117ef61f024f047ceb3 | |
parent | af1ce6c33d65c916894bb8f17544cb80cbe6f902 (diff) | |
download | serenity-8989300851f6ea65437c7c7a489aa92e3ca6e027.zip |
Browser: Assume http:// when no protocol is provided in the location bar (#2142)
-rw-r--r-- | Applications/Browser/Tab.cpp | 11 |
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>(); |