mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:57:44 +00:00
Browser: Allow custom search engine URLs that don't start http[s]://
This commit is contained in:
parent
a1e1405f26
commit
705b7fc407
1 changed files with 5 additions and 4 deletions
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue