diff --git a/scope/helpers.py b/scope/helpers.py index 1ca4cf92..7a1e4008 100644 --- a/scope/helpers.py +++ b/scope/helpers.py @@ -24,9 +24,8 @@ def ss_hosts_parser(hosts): # Raise if credentials are not present if not parts.username or not parts.password: raise ValueError("Missing credentials for SS host: %s" % host) - url = "%s://%s" % (parts.scheme, parts.hostname) - if parts.port: - url = "%s:%s" % (url, parts.port) + # Use netloc instead of hostname and port to maintain capitalization + url = "%s://%s" % (parts.scheme, parts.netloc.split("@")[1]) parsed_hosts[url] = {"user": parts.username, "secret": parts.password} return parsed_hosts diff --git a/scope/tests/test_helpers.py b/scope/tests/test_helpers.py index 72ed0206..6e16d6f8 100644 --- a/scope/tests/test_helpers.py +++ b/scope/tests/test_helpers.py @@ -29,11 +29,13 @@ def test_ss_hosts_parser_success(self): hosts = [ "http://user:secret@localhost:62081", "https://user:secret@192.168.1.128", + "https://user:secret@HOST.com:8000", ] parsed_hosts = helpers.ss_hosts_parser(hosts) expected_hosts = { "http://localhost:62081": {"user": "user", "secret": "secret"}, "https://192.168.1.128": {"user": "user", "secret": "secret"}, + "https://HOST.com:8000": {"user": "user", "secret": "secret"}, } self.assertEqual(parsed_hosts, expected_hosts)