Files
nutshell/cashu/wallet/utils.py
2024-09-08 15:59:10 +02:00

11 lines
393 B
Python

def sanitize_url(url: str) -> str:
# extract host from url and lower case it, remove trailing slash from url
protocol = url.split("://")[0]
host = url.split("://")[1].split("/")[0].lower()
path = (
url.split("://")[1].split("/", 1)[1].rstrip("/")
if "/" in url.split("://")[1]
else ""
)
return f"{protocol}://{host}{'/' + path if path else ''}"