mirror of
https://git.deluge-torrent.org/deluge
synced 2025-04-20 03:24:54 +00:00
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
1 changed files with 6 additions and 0 deletions
|
@ -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()
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue