LibWebView+QT: Support bangs at the end

This commit is contained in:
Saksham Goyal 2024-11-17 17:43:55 -05:00
parent 33c5fd31c1
commit 992c80c355

View file

@ -50,6 +50,18 @@ LocationEdit::LocationEdit(QWidget* parent)
query = MUST(query.substring_from_byte_offset(splits[0].bytes().size()));
}
}
// FIXME: low quality code. this can be merged into the if branch
auto const temp = query.split(' ');
if (!temp.is_error()) {
auto const last = temp.value().last();
if (temp.value().last().starts_with('!')) {
auto exist = WebView::find_search_engine_by_bang(last);
if (exist.has_value()) {
search_engine_url = exist->query_url;
query = MUST(query.substring_from_byte_offset(0, query.bytes().size() - last.bytes().size()));
}
}
}
}
if (auto url = WebView::sanitize_url(query, search_engine_url); url.has_value())