Compare commits
1 Commits
master
...
fix/contex
| Author | SHA1 | Date |
|---|---|---|
|
|
4b6c2a7a72 |
|
|
@ -59,10 +59,10 @@ func parseRemoteURL(remote string) (string, string, error) {
|
|||
}
|
||||
|
||||
func parsePathSegments(path string) (string, string, error) {
|
||||
path = strings.TrimPrefix(path, "/")
|
||||
path = strings.Trim(path, "/")
|
||||
path = strings.TrimSuffix(path, ".git")
|
||||
parts := strings.SplitN(path, "/", 3)
|
||||
if len(parts) < 2 {
|
||||
if len(parts) < 2 || parts[0] == "" || parts[1] == "" {
|
||||
return "", "", fmt.Errorf("cannot extract owner/repo from path: %s", path)
|
||||
}
|
||||
return parts[0], parts[1], nil
|
||||
|
|
|
|||
|
|
@ -76,8 +76,10 @@ func TestParsePathSegments(t *testing.T) {
|
|||
{"with git", "owner/repo.git", "owner", "repo", false},
|
||||
{"leading slash", "/owner/repo", "owner", "repo", false},
|
||||
{"both", "/owner/repo.git", "owner", "repo", false},
|
||||
{"trailing slash", "/owner/repo.git/", "owner", "repo", false},
|
||||
{"with subpath", "owner/repo/sub", "owner", "repo", false},
|
||||
{"single segment", "onlyowner", "", "", true},
|
||||
{"missing repo", "onlyowner/", "", "", true},
|
||||
{"empty", "", "", "", true},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
|
|
|||
Loading…
Reference in New Issue