internal/frontend: simplify isValidPath logic
Change-Id: Iea71fc629dd7cda46418e96ddd4ad36dac0820a9
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/276295
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
diff --git a/internal/frontend/urlinfo.go b/internal/frontend/urlinfo.go
index 0b31e8a..6d16234 100644
--- a/internal/frontend/urlinfo.go
+++ b/internal/frontend/urlinfo.go
@@ -143,20 +143,16 @@
if err := module.CheckImportPath(fullPath); err != nil {
return false
}
+ if fullPath == "golang.org/dl" {
+ // The only golang.org repo that doesn't start with "golang.org/x".
+ return true
+ }
parts := strings.Split(fullPath, "/")
if parts[0] == "golang.org" {
- if fullPath == "golang.org/dl" {
- return true
- }
- if len(parts) >= 3 && parts[1] == "x" {
- return true
- }
- return false
+ return len(parts) >= 3 && parts[1] == "x"
}
- if _, ok := vcsHostsWithThreeElementRepoName[parts[0]]; ok {
- if len(parts) < 3 {
- return false
- }
+ if vcsHostsWithThreeElementRepoName[parts[0]] && len(parts) < 3 {
+ return false
}
return true
}