Use filtered query for map tab

The map tab should only ever pass the raw query (i.e. no "-site:..."
strings), otherwise the maps page will return an error.

Fixes #1048
main
Ben Busby 2023-09-08 16:44:04 -06:00
parent a623210244
commit a35b1dabbc
No known key found for this signature in database
GPG Key ID: B9B7231E01D924A1
2 changed files with 8 additions and 2 deletions

View File

@ -13,7 +13,7 @@
},
"maps": {
"tbm": null,
"href": "https://maps.google.com/maps?q={query}",
"href": "https://maps.google.com/maps?q={map_query}",
"name": "Maps",
"selected": false
},

View File

@ -418,6 +418,10 @@ def get_tabs_content(tabs: dict,
Returns:
dict: contains the name, the href and if the tab is selected or not
"""
map_query = full_query
if '-site:' in full_query:
block_idx = full_query.index('-site:')
map_query = map_query[:block_idx]
tabs = copy.deepcopy(tabs)
for tab_id, tab_content in tabs.items():
# update name to desired language
@ -433,7 +437,9 @@ def get_tabs_content(tabs: dict,
if preferences:
query = f"{query}&preferences={preferences}"
tab_content['href'] = tab_content['href'].format(query=query)
tab_content['href'] = tab_content['href'].format(
query=query,
map_query=map_query)
# update if selected tab (default all tab is selected)
if tab_content['tbm'] == search_type: