mirror of https://gitlab.com/gitlab-org/cli.git
fix: Handle trailing slash in remote URL
This commit is contained in:
parent
26c48951f9
commit
43f6e60bd3
|
@ -45,6 +45,7 @@ func FullNameFromURL(remoteURL string) (string, error) {
|
|||
return "", errors.New("cannot parse remote: " + remoteURL)
|
||||
}
|
||||
repo := parts[1]
|
||||
repo = strings.TrimSuffix(repo, "/")
|
||||
repo = strings.TrimSuffix(repo, ".git")
|
||||
return repo, nil
|
||||
}
|
||||
|
|
|
@ -364,6 +364,21 @@ func TestFullNameFromURL(t *testing.T) {
|
|||
want: "profclems/glab",
|
||||
wantErr: nil,
|
||||
},
|
||||
{
|
||||
remoteURL: "https://gitlab.com/profclems/glab",
|
||||
want: "profclems/glab",
|
||||
wantErr: nil,
|
||||
},
|
||||
{
|
||||
remoteURL: "https://gitlab.com/profclems/glab/",
|
||||
want: "profclems/glab",
|
||||
wantErr: nil,
|
||||
},
|
||||
{
|
||||
remoteURL: "https://gitlab.com/profclems/glab.git/",
|
||||
want: "profclems/glab",
|
||||
wantErr: nil,
|
||||
},
|
||||
{
|
||||
remoteURL: "https://gitlab.com/owner/namespace/repo.git",
|
||||
want: "owner/namespace/repo",
|
||||
|
|
Loading…
Reference in New Issue