diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2021-11-25 16:52:08 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-26 22:14:56 +0100 |
commit | 705b7fc4077798e4871783580e9645248aafe446 (patch) | |
tree | 1f2feb49e25188d3688d067ba93774d33a725a26 /Userland/Applications/Browser/Tab.cpp | |
parent | a1e1405f2636c7251331644bb4ab8cce0a29c61c (diff) | |
download | serenity-705b7fc4077798e4871783580e9645248aafe446.zip |
Browser: Allow custom search engine URLs that don't start http[s]://
Diffstat (limited to 'Userland/Applications/Browser/Tab.cpp')
-rw-r--r-- | Userland/Applications/Browser/Tab.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp index 2463a7e21d..ca65ca6803 100644 --- a/Userland/Applications/Browser/Tab.cpp +++ b/Userland/Applications/Browser/Tab.cpp @@ -40,16 +40,17 @@ namespace Browser { URL url_from_user_input(const String& input) { - if (input.starts_with("?") && !g_search_engine.is_null()) - return URL(g_search_engine.replace("{}", URL::percent_encode(input.substring_view(1)))); + String url_string = input; + if (input.starts_with("?") && !g_search_engine.is_empty()) + url_string = g_search_engine.replace("{}", URL::percent_encode(input.substring_view(1))); - auto url = URL(input); + URL url = URL(url_string); if (url.is_valid()) return url; StringBuilder builder; builder.append("http://"); - builder.append(input); + builder.append(url_string); return URL(builder.build()); } |