diff --git a/bookwyrm/book_search.py b/bookwyrm/book_search.py index 29c48c936..4ea4c14a8 100644 --- a/bookwyrm/book_search.py +++ b/bookwyrm/book_search.py @@ -32,7 +32,7 @@ def isbn_search(query): return [] # Up-case the ISBN string to ensure any 'X' check-digit is correct # If the ISBN has only 9 characters, prepend missing zero - query = query.upper().rjust(10, '0') + query = query.strip().upper().rjust(10, '0') filters = [{f: query} for f in ["isbn_10", "isbn_13"]] results = models.Edition.objects.filter( reduce(operator.or_, (Q(**f) for f in filters)) diff --git a/bookwyrm/connectors/abstract_connector.py b/bookwyrm/connectors/abstract_connector.py index 87cae00c0..32559a307 100644 --- a/bookwyrm/connectors/abstract_connector.py +++ b/bookwyrm/connectors/abstract_connector.py @@ -44,9 +44,8 @@ class AbstractMinimalConnector(ABC): if maybe_isbn(query) and self.isbn_search_url and self.isbn_search_url != "": # Up-case the ISBN string to ensure any 'X' check-digit is correct # If the ISBN has only 9 characters, prepend missing zero - query = query.upper().rjust(10, '0') - return f"{self.isbn_search_url}{query}" - + normalized_query = query.strip().upper().rjust(10, '0') + return f"{self.isbn_search_url}{normalized_query}" # NOTE: previously, we tried searching isbn and if that produces no results, # searched as free text. This, instead, only searches isbn if it's isbn-y return f"{self.search_url}{query}"