Skip to content

Commit a038032

Browse files
committed
Automatically convert ASIN to uppercase
1 parent 6f955a9 commit a038032

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

amazon_paapi/tools/asin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
def get_asin(text: str) -> str:
88
"""Returns the ASIN from a given text. Raises AsinNotFoundException on fail."""
99
# Return if text is an ASIN
10-
if re.search(r'^[A-Z0-9]{10}$', text):
11-
return text
10+
if re.search(r'^[a-zA-Z0-9]{10}$', text):
11+
return text.upper()
1212

1313
# Extract ASIN from URL searching for alphanumeric and 10 digits
1414
asin = re.search(r'(dp|gp/product|gp/aw/d|dp/product)/([a-zA-Z0-9]{10})', text)
1515
if asin:
16-
return asin.group(2)
16+
return asin.group(2).upper()
1717

1818
raise AsinNotFoundException('Asin not found: ' + text)

0 commit comments

Comments
 (0)