From a105da84747df637fa7913c3ab880be73019e502 Mon Sep 17 00:00:00 2001 From: merlin Date: Wed, 26 Jul 2023 12:15:52 +0300 Subject: plumbing: transport, handle IPv6 while parsing endpoint. Fixes #740 --- plumbing/transport/common.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'plumbing/transport/common.go') diff --git a/plumbing/transport/common.go b/plumbing/transport/common.go index 89bd3d5..c6a054a 100644 --- a/plumbing/transport/common.go +++ b/plumbing/transport/common.go @@ -227,11 +227,17 @@ func parseURL(endpoint string) (*Endpoint, error) { pass, _ = u.User.Password() } + host := u.Hostname() + if strings.Contains(host, ":") { + // IPv6 address + host = "[" + host + "]" + } + return &Endpoint{ Protocol: u.Scheme, User: user, Password: pass, - Host: u.Hostname(), + Host: host, Port: getPort(u), Path: getPath(u), }, nil -- cgit