Support www.github.com git remote URLs

This commit is contained in:
Mislav Marohnić 2020-03-27 13:55:16 +01:00
parent c17251d106
commit 303f60815f
2 changed files with 7 additions and 1 deletions

View file

@ -33,7 +33,7 @@ func FromFullName(nwo string) Interface {
}
func FromURL(u *url.URL) (Interface, error) {
if !strings.EqualFold(u.Hostname(), defaultHostname) {
if !strings.EqualFold(u.Hostname(), defaultHostname) && !strings.EqualFold(u.Hostname(), "www."+defaultHostname) {
return nil, fmt.Errorf("unsupported hostname: %s", u.Hostname())
}
parts := strings.SplitN(strings.TrimPrefix(u.Path, "/"), "/", 3)

View file

@ -20,6 +20,12 @@ func Test_repoFromURL(t *testing.T) {
result: "monalisa/octo-cat",
err: nil,
},
{
name: "www.github.com URL",
input: "http://www.GITHUB.com/monalisa/octo-cat.git",
result: "monalisa/octo-cat",
err: nil,
},
{
name: "unsupported hostname",
input: "https://example.com/one/two",