Fix issues

This commit is contained in:
2021-03-28 19:53:14 +02:00
parent b7315c2348
commit 8eae777265
5 changed files with 22 additions and 32 deletions

View File

@@ -174,13 +174,21 @@ def parse_uri(uri: str):
return host, port, path
def get_uri(url: str):
def uri_from_url(url: str):
"""
Returns a valid URI of the specified URL.
"""
parsed = urlsplit(url)
result = f"http://{parsed.netloc}{parsed.path}"
if parsed.hostname is None:
url = f"http://{url}"
parsed = urlsplit(url)
path = parsed.path
if path == "":
path = "/"
result = f"http://{parsed.netloc}{path}"
if parsed.query != "":
result = f"{result}?{parsed.query}"