From 66b7a3d193af9927fe7f2801f61039c54f2019d9 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 31 Mar 2021 12:03:58 -0700 Subject: [PATCH] Avoids error on empty search query --- bookwyrm/connectors/connector_manager.py | 2 ++ bookwyrm/views/search.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bookwyrm/connectors/connector_manager.py b/bookwyrm/connectors/connector_manager.py index 3ed25ceb..853609de 100644 --- a/bookwyrm/connectors/connector_manager.py +++ b/bookwyrm/connectors/connector_manager.py @@ -15,6 +15,8 @@ class ConnectorException(HTTPError): def search(query, min_confidence=0.1): """ find books based on arbitary keywords """ + if not query: + return [] results = [] # Have we got a ISBN ? diff --git a/bookwyrm/views/search.py b/bookwyrm/views/search.py index 18bf1d40..28f393c8 100644 --- a/bookwyrm/views/search.py +++ b/bookwyrm/views/search.py @@ -31,7 +31,7 @@ class Search(View): return JsonResponse([r.json() for r in book_results], safe=False) # use webfinger for mastodon style account@domain.com username - if re.match(regex.full_username, query): + if query and re.match(regex.full_username, query): handle_remote_webfinger(query) # do a user search @@ -73,6 +73,6 @@ class Search(View): "book_results": book_results, "user_results": user_results, "list_results": list_results, - "query": query, + "query": query or "", } return TemplateResponse(request, "search_results.html", data)