internal/frontend: simplify isValidPath logic
Trust: Jonathan Amsterdam
Run-TryBot: Jonathan Amsterdam
TryBot-Result: kokoro
@@ -143,21 +143,17 @@ func isValidPath(fullPath string) bool {
if err := module.CheckImportPath(fullPath); err != nil {
return false
}
- parts := strings.Split(fullPath, "/")
- if parts[0] == "golang.org" {
if fullPath == "golang.org/dl" {
+ // The only golang.org repo that doesn't start with "golang.org/x".
return true
}
- if len(parts) >= 3 && parts[1] == "x" {
- return true
- }
- return false
+ parts := strings.Split(fullPath, "/")
+ if parts[0] == "golang.org" {
+ return len(parts) >= 3 && parts[1] == "x"
}
- if _, ok := vcsHostsWithThreeElementRepoName[parts[0]]; ok {
- if len(parts) < 3 {
+ if vcsHostsWithThreeElementRepoName[parts[0]] && len(parts) < 3 {
return false
}
- }
return true
}
