[GH-ISSUE #595] [FEATURE] Bangs without any search term should redirect to the homepage #380

Closed
opened 2026-02-25 20:35:36 +03:00 by kerem · 2 comments
Owner

Originally created by @lenicyl on GitHub (Dec 28, 2021).
Original GitHub issue: https://github.com/benbusby/whoogle-search/issues/595

Currently Whoogle bangs work this way :
!yt <search term> redirects to https://www.youtube.com/results?search_query=<search term> which is nice

However if you use the bang !yt without really adding any search terms it again redirects to https://www.youtube.com/results?search_query= which is somewhat annoying

It would be nice if it were to be changed so that if a search term isnt used, it redirects to the homepage, which in the examples used above would mean !yt redirects to https://youtube.com

Originally created by @lenicyl on GitHub (Dec 28, 2021). Original GitHub issue: https://github.com/benbusby/whoogle-search/issues/595 Currently Whoogle bangs work this way : `!yt <search term>` redirects to `https://www.youtube.com/results?search_query=<search term>` which is nice However if you use the bang `!yt` without really adding any search terms it again redirects to `https://www.youtube.com/results?search_query=` which is somewhat annoying It would be nice if it were to be changed so that if a search term isnt used, it redirects to the homepage, which in the examples used above would mean `!yt` redirects to `https://youtube.com`
kerem 2026-02-25 20:35:36 +03:00
Author
Owner

@Albonycal commented on GitHub (Dec 28, 2021):

hmm maybe I could work on this
@benbusby

<!-- gh-comment-id:1001963122 --> @Albonycal commented on GitHub (Dec 28, 2021): hmm maybe I could work on this @benbusby
Author
Owner

@benbusby commented on GitHub (Dec 28, 2021):

@Albonycal sure. You'd just need to modify app/utils/bangs.py -> resolve_bang() to make sure the URL replacement value isn't empty first. So something like (pseudocode-ish):

def resolve_bang
    # ... rest of function ...
    bang_query = query.replace(operator if operator in split_query
                               else operator[1:] + operator[0], '').strip(), 1)
    if bang_query:
        return bangs_dict[operator]['url'].replace('{}', bang_query)
    return ''
<!-- gh-comment-id:1002230558 --> @benbusby commented on GitHub (Dec 28, 2021): @Albonycal sure. You'd just need to modify `app/utils/bangs.py -> resolve_bang()` to make sure the URL replacement value isn't empty first. So something like (pseudocode-ish): ```py def resolve_bang # ... rest of function ... bang_query = query.replace(operator if operator in split_query else operator[1:] + operator[0], '').strip(), 1) if bang_query: return bangs_dict[operator]['url'].replace('{}', bang_query) return '' ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/whoogle-search#380
No description provided.