api/internal/git: handle .git suffix in repospec

This change adds a new test case for parsing url with `.git` suffix. In
that case, we should have the full url as clone spec with an empty
abspath.
This commit is contained in:
Haibing Zhou
2021-07-05 13:07:57 -07:00
parent d818ccae92
commit 8c14b9d1af
2 changed files with 7 additions and 1 deletions

View File

@@ -125,7 +125,7 @@ func parseGitUrl(n string) (
index := strings.Index(n, gitSuffix)
orgRepo = n[0:index]
n = n[index+len(gitSuffix):]
if n[0] == '/' {
if len(n) > 0 && n[0] == '/' {
n = n[1:]
}
path, gitRef, gitTimeout, gitSubmodules = peelQuery(n)