Make bang searches case insensitive (#438)
Bang searches now ignore the capitalization of the operator Co-authored-by: Ben Busby <noreply+git@benbusby.com>main
parent
27d978f232
commit
f12b0e62c5
|
@ -51,6 +51,8 @@ def resolve_bang(query: str, bangs_dict: dict) -> str:
|
|||
wasn't a match or didn't contain a bang operator
|
||||
|
||||
"""
|
||||
# Ensure bang search is case insensitive
|
||||
query = query.lower()
|
||||
split_query = query.split(' ')
|
||||
for operator in bangs_dict.keys():
|
||||
if operator not in split_query:
|
||||
|
|
|
@ -36,6 +36,11 @@ def test_ddg_bang(client):
|
|||
assert rv._status_code == 302
|
||||
assert rv.headers.get('Location').startswith('https://www.reddit.com')
|
||||
|
||||
# Ensure bang is case insensitive
|
||||
rv = client.get('/search?q=!GH%20whoogle')
|
||||
assert rv._status_code == 302
|
||||
assert rv.headers.get('Location').startswith('https://github.com')
|
||||
|
||||
|
||||
def test_config(client):
|
||||
rv = client.post('/config', data=demo_config)
|
||||
|
|
Loading…
Reference in New Issue