diff --git a/internal/notifier/util.go b/internal/notifier/util.go index f31e8ec..c6c60dc 100644 --- a/internal/notifier/util.go +++ b/internal/notifier/util.go @@ -32,14 +32,9 @@ func parseGitAddress(s string) (string, string, error) { return "", "", nil } - path := strings.TrimLeft(u.Path, "/") - comp := strings.Split(path, "/") - if len(comp) != 2 { - return "", "", fmt.Errorf("Incorrectly formatted git address: %v", s) - } - + id := strings.TrimLeft(u.Path, "/") + id = strings.TrimSuffix(id, ".git") host := fmt.Sprintf("https://%s", u.Host) - id := comp[0] + "/" + strings.TrimSuffix(comp[1], ".git") return host, id, nil } diff --git a/internal/notifier/util_test.go b/internal/notifier/util_test.go index fb426dc..d65be75 100644 --- a/internal/notifier/util_test.go +++ b/internal/notifier/util_test.go @@ -95,3 +95,11 @@ func TestUtil_ParseGitSshWithProtocol(t *testing.T) { require.Equal(t, "https://github.com", host) require.Equal(t, "stefanprodan/podinfo", id) } + +func TestUtil_ParseGitHttpWithSubgroup(t *testing.T) { + addr := "https://gitlab.com/foo/bar/foo.git" + host, id, err := parseGitAddress(addr) + require.NoError(t, err) + require.Equal(t, "https://gitlab.com", host) + require.Equal(t, "foo/bar/foo", id) +}