1
0
Fork 0

normalise isbn on local book search

- uppercase ISBN before checking it's a number to account for trailing 'x'
- check maybe_isbn for search_identifiers search. Without this we are only searching external connectors, not locally!
This commit is contained in:
Hugh Rundle 2022-08-30 20:00:09 +10:00
parent 68d91086ed
commit 1ee2ff4811
3 changed files with 8 additions and 3 deletions

View file

@ -328,10 +328,10 @@ def maybe_isbn(query):
"""check if a query looks like an isbn"""
isbn = re.sub(r"[\W_]", "", query) # removes filler characters
# ISBNs must be numeric except an ISBN10 checkdigit can be 'X'
if not isbn.rstrip("X").isnumeric():
if not isbn.upper().rstrip("X").isnumeric():
return False
return len(isbn) in [
9,
10,
13,
] # ISBN10 or ISBN13, or maybe ISBN10 missing a prepended zero
] # ISBN10 or ISBN13, or maybe ISBN10 missing a leading zero