mirror of
https://github.com/searxng/searxng.git
synced 2024-11-18 08:51:06 +00:00
Merge pull request #2369 from Jorengarenar/master
Go to main instead of search page when external bang query is empty
This commit is contained in:
commit
12df30070b
1 changed files with 8 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# 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
|
from searx.data import EXTERNAL_BANGS
|
||||||
|
|
||||||
LEAF_KEY = chr(16)
|
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):
|
def resolve_bang_definition(bang_definition, query):
|
||||||
url, rank = bang_definition.split(chr(1))
|
url, rank = bang_definition.split(chr(1))
|
||||||
url = url.replace(chr(2), quote_plus(query))
|
|
||||||
if url.startswith('//'):
|
if url.startswith('//'):
|
||||||
url = 'https:' + url
|
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
|
rank = int(rank) if len(rank) > 0 else 0
|
||||||
return (url, rank)
|
return (url, rank)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue