Fixes #4346: allow git+https URL protocol

This commit is contained in:
Dan Burzo 2021-09-20 19:35:06 +03:00
parent bb86145cb6
commit 9f43967042
2 changed files with 30 additions and 0 deletions

View file

@ -14,6 +14,7 @@ func isSupportedProtocol(u string) bool {
strings.HasPrefix(u, "git+ssh:") ||
strings.HasPrefix(u, "git:") ||
strings.HasPrefix(u, "http:") ||
strings.HasPrefix(u, "git+https:") ||
strings.HasPrefix(u, "https:")
}
@ -43,6 +44,10 @@ func ParseURL(rawURL string) (u *url.URL, err error) {
u.Scheme = "ssh"
}
if u.Scheme == "git+https" {
u.Scheme = "https"
}
if u.Scheme != "ssh" {
return
}

View file

@ -28,11 +28,26 @@ func TestIsURL(t *testing.T) {
url: "git://example.com/owner/repo",
want: true,
},
{
name: "git with extension",
url: "git://example.com/owner/repo.git",
want: true,
},
{
name: "git+ssh",
url: "git+ssh://git@example.com/owner/repo.git",
want: true,
},
{
name: "https",
url: "https://example.com/owner/repo.git",
want: true,
},
{
name: "git+https",
url: "git+https://example.com/owner/repo.git",
want: true,
},
{
name: "no protocol",
url: "example.com/owner/repo",
@ -121,6 +136,16 @@ func TestParseURL(t *testing.T) {
Path: "/owner/repo.git",
},
},
{
name: "git+https",
url: "git+https://example.com/owner/repo.git",
want: url{
Scheme: "https",
User: "",
Host: "example.com",
Path: "/owner/repo.git",
},
},
{
name: "scp-like",
url: "git@example.com:owner/repo.git",