Skip to content

Commit

Permalink
use cut instead of split
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxys committed Jan 13, 2024
1 parent df93873 commit 6a2ff19
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions server/model/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ func (r *Repo) ResetVisibility() {

// ParseRepo parses the repository owner and name from a string.
func ParseRepo(str string) (user, repo string, err error) {
parts := strings.Split(str, "/")
if len(parts) != 2 {
err = fmt.Errorf("error: Invalid or missing repository. eg octocat/hello-world")
before, after, _ := strings.Cut(str, "/")
if before == "" || after == "" {
err = fmt.Errorf("invalid or missing repository (e.g. octocat/hello-world)")
return
}
user = parts[0]
repo = parts[1]
user = before
repo = after
return
}

Expand Down

0 comments on commit 6a2ff19

Please sign in to comment.