Skip to content

Commit b3d1fd2

Browse files
committed
fix: use net.JoinHostPort for IPv6 support in protocol fallback
String concatenation doesn't properly handle IPv6 addresses which need brackets. Example: [::1]:443 would become ::1:80 instead of [::1]:80 Uses net.JoinHostPort() which correctly formats IPv6 addresses.
1 parent afd5951 commit b3d1fd2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

runner/runner.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,14 +1760,14 @@ retry:
17601760
// if port is 443 (default HTTPS), switch to 80 (default HTTP)
17611761
if URL.Port() == "443" {
17621762
URL.UpdatePort("80")
1763-
target.Host = URL.Hostname() + ":80"
1763+
target.Host = net.JoinHostPort(URL.Hostname(), "80")
17641764
}
17651765
} else {
17661766
protocol = httpx.HTTPS
17671767
// if port is 80 (default HTTP), switch to 443 (default HTTPS)
17681768
if URL.Port() == "80" {
17691769
URL.UpdatePort("443")
1770-
target.Host = URL.Hostname() + ":443"
1770+
target.Host = net.JoinHostPort(URL.Hostname(), "443")
17711771
}
17721772
}
17731773
retried = true

0 commit comments

Comments
 (0)