diff options
author | Jakub Ćukasiewicz <dev@joren.ga> | 2023-04-24 19:11:59 +0200 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2023-04-25 15:02:34 +0200 |
commit | 7da47edd93a21175bb71377ef060e5d46d4fe832 (patch) | |
tree | 203624f54cf91838dc86665e5d3d2234b2c52a6f /searx | |
parent | 98387e291059d662dfb1da0ba131ca25da8b8d3c (diff) | |
download | searxng-7da47edd93a21175bb71377ef060e5d46d4fe832.tar.gz searxng-7da47edd93a21175bb71377ef060e5d46d4fe832.zip |
[mod] external bang: go to main instead of search page when query is empty
Closes: #2368
Diffstat (limited to 'searx')
-rw-r--r-- | searx/external_bang.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/searx/external_bang.py b/searx/external_bang.py index 20de9c77f..0336d880b 100644 --- a/searx/external_bang.py +++ b/searx/external_bang.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -from urllib.parse import quote_plus +from urllib.parse import quote_plus, urlparse from searx.data import EXTERNAL_BANGS LEAF_KEY = chr(16) @@ -40,9 +40,15 @@ def get_bang_definition_and_ac(external_bangs_db, bang): def resolve_bang_definition(bang_definition, query): url, rank = bang_definition.split(chr(1)) - url = url.replace(chr(2), quote_plus(query)) if url.startswith('//'): url = 'https:' + url + if query: + url = url.replace(chr(2), quote_plus(query)) + else: + # go to main instead of search page + o = urlparse(url) + url = o.scheme + '://' + o.netloc + rank = int(rank) if len(rank) > 0 else 0 return (url, rank) |