Use net.JoinHostPort and net.SplitHostPort for IPv6-safe host:port handling (#5836)

This commit is contained in:
Viktor Liu
2026-04-10 09:10:57 +08:00
committed by GitHub
parent 0cc90e2a8a
commit f484835292
21 changed files with 193 additions and 36 deletions

View File

@@ -3,6 +3,7 @@ package server
import (
"context"
"encoding/json"
"net"
"net/http"
"net/http/httptest"
"runtime"
@@ -52,7 +53,7 @@ func Test_S3HandlerGetUploadURL(t *testing.T) {
hostIP, err := c.Host(ctx)
require.NoError(t, err)
awsEndpoint := "http://" + hostIP + ":" + mappedPort.Port()
awsEndpoint := "http://" + net.JoinHostPort(hostIP, mappedPort.Port())
t.Setenv("AWS_REGION", awsRegion)
t.Setenv("AWS_ENDPOINT_URL", awsEndpoint)