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
BlissOWL 2021-09-28 07:09:58 +05:30 committed by GitHub
parent 27d978f232
commit f12b0e62c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -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:

View File

@ -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)