fix(links): bracket ipv6 hosts in share links and qr codes (#5310)

* fix(sub): bracket ipv6 hosts in share links

* fix(frontend): bracket ipv6 hosts in share links
This commit is contained in:
Nikan Zeyaei
2026-06-15 01:08:58 +03:30
committed by GitHub
parent 335470607f
commit 7c737820d1
4 changed files with 135 additions and 13 deletions
+19
View File
@@ -426,6 +426,25 @@ func TestCloneStringMap_Empty(t *testing.T) {
}
}
func TestJoinHostPort(t *testing.T) {
cases := []struct {
host string
port int
want string
}{
{"example.com", 443, "example.com:443"},
{"1.2.3.4", 443, "1.2.3.4:443"},
{"2001:db8::1", 443, "[2001:db8::1]:443"},
{"[2001:db8::1]", 443, "[2001:db8::1]:443"},
{"2001:db8::1", 8080, "[2001:db8::1]:8080"},
}
for _, c := range cases {
if got := joinHostPort(c.host, c.port); got != c.want {
t.Fatalf("joinHostPort(%q, %d) = %q, want %q", c.host, c.port, got, c.want)
}
}
}
func TestGetHostFromXFH_HostOnly(t *testing.T) {
got, err := getHostFromXFH("example.com")
if err != nil {