mirror of
http://git.nowherejezfoltodf4jiyl6r56jnzintap5vyjlia7fkirfsnfizflqd.onion/nihilist/darknet-lantern.git
synced 2025-05-17 04:36:57 +00:00
fix simplex parsing
This commit is contained in:
parent
13d39dc5c2
commit
013673fffb
2 changed files with 9 additions and 6 deletions
|
@ -20,17 +20,18 @@ hostname_pattern = re.compile(r'^(?:[a-zA-Z0-9.-]+|[0-9]{1,3}(?:\.[0-9]{1,3}){3}
|
|||
def IsSimpleXChatroomValid(url: str) -> bool:
|
||||
"""Validate the SimpleX chatroom URL."""
|
||||
REQUIRED_SUBSTRING = "contact#/?v=2-7&smp=smp%3A%2F"
|
||||
REQUIRED_SUBSTRING2 = "contact/#/?v=2-7&smp=smp%3A%2F"
|
||||
|
||||
# Step 1: Check if it starts with http://, https://, or simplex:/
|
||||
if url.startswith(('http://', 'https://', 'simplex:/')):
|
||||
# Step 1.5: If http:// or https://, check for valid clearnet or onion domain
|
||||
if url.startswith(('http://', 'https://')):
|
||||
return IsUrlValid(url)
|
||||
if url.startswith(('http://', 'https://')) and not IsUrlValid(url):
|
||||
return False
|
||||
elif not url.startswith('simplex:/'):
|
||||
return False # Must start with one of the valid protocols
|
||||
|
||||
# Step 2: Check for the presence of the required substring
|
||||
if REQUIRED_SUBSTRING not in url:
|
||||
if REQUIRED_SUBSTRING not in url and REQUIRED_SUBSTRING2 not in url:
|
||||
return False # Required substring not found
|
||||
|
||||
# Step 3: Extract the part after "smp=smp%3A%2F"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue