mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 08:08:43 +00:00
Browser: Allow custom search engine URLs that don't start http[s]://
This commit is contained in:
parent
a1e1405f26
commit
705b7fc407
Notes:
sideshowbarker
2024-07-18 00:39:04 +09:00
Author: https://github.com/AtkinsSJ
Commit: 705b7fc407
Pull-request: https://github.com/SerenityOS/serenity/pull/11072
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