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:
parent
4f0c786649
commit
79b7e6093f
@ -699,6 +699,9 @@ def is_url(url):
|
|||||||
True
|
True
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
if not url:
|
||||||
|
return False
|
||||||
|
|
||||||
return url.partition('://')[0] in ('http', 'https', 'ftp', 'udp')
|
return url.partition('://')[0] in ('http', 'https', 'ftp', 'udp')
|
||||||
|
|
||||||
|
|
||||||
@ -713,6 +716,9 @@ def is_infohash(infohash):
|
|||||||
bool: True if valid infohash, False otherwise.
|
bool: True if valid infohash, False otherwise.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
if not infohash:
|
||||||
|
return False
|
||||||
|
|
||||||
return len(infohash) == 40 and infohash.isalnum()
|
return len(infohash) == 40 and infohash.isalnum()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user