Fix parsing IPv6 remote URLs (#8893)
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
This commit is contained in:
parent
2c53d7c9a8
commit
47efef6d70
2 changed files with 21 additions and 3 deletions
|
|
@ -56,9 +56,7 @@ func ParseURL(rawURL string) (u *url.URL, err error) {
|
|||
u.Path = strings.TrimPrefix(u.Path, "/")
|
||||
}
|
||||
|
||||
if idx := strings.Index(u.Host, ":"); idx >= 0 {
|
||||
u.Host = u.Host[0:idx]
|
||||
}
|
||||
u.Host = strings.TrimSuffix(u.Host, ":"+u.Port())
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,6 +126,26 @@ func TestParseURL(t *testing.T) {
|
|||
Path: "/owner/repo.git",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ssh, ipv6",
|
||||
url: "ssh://git@[::1]/owner/repo.git",
|
||||
want: url{
|
||||
Scheme: "ssh",
|
||||
User: "git",
|
||||
Host: "[::1]",
|
||||
Path: "/owner/repo.git",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ssh with port, ipv6",
|
||||
url: "ssh://git@[::1]:22/owner/repo.git",
|
||||
want: url{
|
||||
Scheme: "ssh",
|
||||
User: "git",
|
||||
Host: "[::1]",
|
||||
Path: "/owner/repo.git",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "git+ssh",
|
||||
url: "git+ssh://example.com/owner/repo.git",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue