8000 Simplify the URL parsing · localstack/localstack@6eeb953 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6eeb953

Browse files
Simplify the URL parsing
1 parent 3794647 commit 6eeb953

File tree

1 file changed

+13
-11
lines changed
  • localstack-core/localstack/utils

1 file changed

+13
-11
lines changed

localstack-core/localstack/utils/java.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,22 @@ def java_system_properties_proxy() -> dict[str, str]:
2626
"""
2727
props = {}
2828

29-
for scheme, default_port, var in [
29+
for scheme, default_port, proxy_url in [
3030
("http", "80", config.OUTBOUND_HTTP_PROXY),
3131
("https", "443", config.OUTBOUND_HTTPS_PROXY),
3232
]:
33-
if var:
34-
netloc = urlparse(var).netloc
35-
url = netloc.split(":")
36-
if len(url) == 2:
37-
hostname, port = url
38-
else:
39-
hostname, port = url[0], default_port
40-
41-
props[f"{scheme}.proxyHost"] = hostname
42-
props[f"{scheme}.proxyPort"] = port
33+
if proxy_url:
34+
parsed_url = urlparse(proxy_url)
35+
36+
port: int | None = parsed_url.port
37+
7026 if port is None:
38+
if scheme == "https":
39+
port = 443
40+
else:
41+
port = 80
42+
43+
props[f"{scheme}.proxyHost"] = parsed_url.hostname
44+
props[f"{scheme}.proxyPort"] = str(port)
4345

4446
return props
4547

0 commit comments

Comments
 (0)
0