sanitize mint URL before adding (#606)

This commit is contained in:
callebtc
2024-09-08 15:59:10 +02:00
committed by GitHub
parent ef5aee92d6
commit 0287c02f97
3 changed files with 84 additions and 7 deletions

10
cashu/wallet/utils.py Normal file
View File

@@ -0,0 +1,10 @@
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 ''}"