mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-24 03:54:21 +01:00
sanitize mint URL before adding (#606)
This commit is contained in:
10
cashu/wallet/utils.py
Normal file
10
cashu/wallet/utils.py
Normal 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 ''}"
|
||||
Reference in New Issue
Block a user