Updated search view to trim leading and trailing whitespace for author, book, and list query values

This commit is contained in:
Tim Rogers 2024-08-11 13:01:48 -05:00
parent 95c2798fc7
commit 2bb77d9bf8

View file

@ -53,7 +53,7 @@ class Search(View):
def api_book_search(request): def api_book_search(request):
"""Return books via API response""" """Return books via API response"""
query = request.GET.get("q") query = request.GET.get("q").strip()
query = isbn_check_and_format(query) query = isbn_check_and_format(query)
min_confidence = request.GET.get("min_confidence", 0) min_confidence = request.GET.get("min_confidence", 0)
# only return local book results via json so we don't cascade # only return local book results via json so we don't cascade
@ -65,7 +65,7 @@ def api_book_search(request):
def book_search(request): def book_search(request):
"""the real business is elsewhere""" """the real business is elsewhere"""
query = request.GET.get("q") query = request.GET.get("q").strip()
# check if query is isbn # check if query is isbn
query = isbn_check_and_format(query) query = isbn_check_and_format(query)
min_confidence = request.GET.get("min_confidence", 0) min_confidence = request.GET.get("min_confidence", 0)
@ -123,8 +123,7 @@ def author_search(request):
def user_search(request): def user_search(request):
"""user search: search for a user""" """user search: search for a user"""
viewer = request.user viewer = request.user
query = request.GET.get("q") query = request.GET.get("q").strip()
query = query.strip()
data = {"type": "user", "query": query} data = {"type": "user", "query": query}
# use webfinger for mastodon style account@domain.com username to load the user if # use webfinger for mastodon style account@domain.com username to load the user if
@ -162,7 +161,7 @@ def user_search(request):
def list_search(request): def list_search(request):
"""any relevent lists?""" """any relevent lists?"""
query = request.GET.get("q") query = request.GET.get("q").strip()
data = {"query": query, "type": "list"} data = {"query": query, "type": "list"}
results = ( results = (
models.List.privacy_filter( models.List.privacy_filter(