File tree Expand file tree Collapse file tree 1 file changed +8
-15
lines changed Expand file tree Collapse file tree 1 file changed +8
-15
lines changed Original file line number Diff line number Diff line change @@ -21,23 +21,16 @@ var (
2121
2222// getGitHubRepo parses and extracts the repository path from a GitHub URL.
2323func getGitHubRepo (url string ) (string , error ) {
24- h , hFound := strings .CutPrefix (url , hPrefix )
25- p , found := strings .CutPrefix (url , prefix )
26-
27- switch {
28- case hFound :
29- if isInvalidFormat (h ) {
30- return "" , ErrNotValidURLFormat
31- }
32- return h , nil
33- case found :
34- if isInvalidFormat (p ) {
35- return "" , ErrNotValidURLFormat
24+ prefixes := []string {hPrefix , prefix }
25+ for _ , pref := range prefixes {
26+ if path , ok := strings .CutPrefix (url , pref ); ok {
27+ if isInvalidFormat (path ) {
28+ return "" , ErrNotValidURLFormat
29+ }
30+ return path , nil
3631 }
37- return p , nil
38- default :
39- return "" , ErrNotValidURL
4032 }
33+ return "" , ErrNotValidURL
4134}
4235
4336// isInvalidFormat checks if the URL has an invalid format.
You can’t perform that action at this time.
0 commit comments