github.com/ungtb10d/cli/v2@v2.0.0-20221110210412-98537dd9d6a1/pkg/cmd/repo/shared/repo.go (about) 1 package shared 2 3 import ( 4 "regexp" 5 "strings" 6 ) 7 8 var invalidCharactersRE = regexp.MustCompile(`[^\w._-]+`) 9 10 // NormalizeRepoName takes in the repo name the user inputted and normalizes it using the same logic as GitHub (GitHub.com/new) 11 func NormalizeRepoName(repoName string) string { 12 newName := invalidCharactersRE.ReplaceAllString(repoName, "-") 13 return strings.TrimSuffix(newName, ".git") 14 }