Fix is_url and is_infohash error with None value

Encountered a TypeError with None value passed to is_infohash function
so add guard clause.
This commit is contained in:
Calum Lind 2022-01-08 13:54:30 +00:00
parent 4f0c786649
commit 79b7e6093f
No known key found for this signature in database
GPG Key ID: 90597A687B836BA3

View File

@ -699,6 +699,9 @@ def is_url(url):
True
"""
if not url:
return False
return url.partition('://')[0] in ('http', 'https', 'ftp', 'udp')
@ -713,6 +716,9 @@ def is_infohash(infohash):
bool: True if valid infohash, False otherwise.
"""
if not infohash:
return False
return len(infohash) == 40 and infohash.isalnum()