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 Mar 14, 2024
1 parent e861b9d commit 629e1e3
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 629e1e3

Please sign in to comment.