try url split

This commit is contained in:
Lane Jennison
2021-12-11 23:21:31 -05:00
parent a509d90043
commit 2b0da41c2d
2 changed files with 6 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
""" flask app to redirect request to appropriate armbian mirror and image """
from json import dumps
from urllib.parse import urlsplit
try:
import uwsgi
@@ -97,7 +98,10 @@ def get_redirect(path, client_ip, scheme, mirror_class=mirror, dl_map=DL_MAP):
""" prepend scheme from client request if not given by mirror url
allow schemes from 3 (ftp) to 5 (https) character length """
mirror_url = mirror_class.next(region)
if mirror_url.find('://', 3, 8) == -1:
mirror_url_parsed = urlsplit(mirror_url, allow_fragments=True)
mirror_scheme = mirror_url_parsed.scheme
print(f"thing {mirror_scheme}")
if not mirror_scheme:
mirror_url = scheme + '://' + mirror_url
if mirror_class.mode == "dl_map" and len(split_path) == 2:

View File

@@ -21,6 +21,7 @@ def test_get_redirect(mocker, path):
repos = [
'example.com/repo/',
'exampler2.com/nested/repo/',
'exampler3.com/wild/repo/'
]
self.choice = random.choice(repos)
return self.choice