issue #25: all test checked and passed. the funcs in the utils file are specifically for this folder don't use elsewhere

This commit is contained in:
SovereigntyIsNotFreedom 2025-04-07 12:41:21 +01:00
parent fb09b21684
commit 574a11fdc5
3 changed files with 37 additions and 50 deletions

View file

@ -5,7 +5,7 @@ def IsOnionValid(url: str)-> bool:
Checks if the domain(param) is a valid onion domain and return True else False.
"""
try:
pattern = re.compile("^[A-Za-z0-9.]+(.onion)?$")
pattern = re.compile(r"^[A-Za-z0-9:/._%-=#?&@]+(.onion)$")
url = url.strip().removesuffix('/')
if url.startswith('http://'):
domain = url.split('/')[2]
@ -40,7 +40,7 @@ def IsUrlValid(url:str)->bool:
"""
Check if url is valid both dark net end clearnet.
"""
pattern = re.compile("^[A-Za-z0-9:/.-]+$")
pattern = re.compile(r"^[A-Za-z0-9:/._%-=#?&@]+$")
url = str(url)
if len(url) < 4:
return False
@ -51,4 +51,4 @@ def IsUrlValid(url:str)->bool:
return False
if pattern.fullmatch(url) is None:
return False
return True
return True