internal/frontend: accept golang.org/dl/* paths
Treat any path beginning "golang.org/dl/" as valid, not just
"golang.org/dl" itself.
Fixes golang/go#43204
Change-Id: I11fbe8b4d935bfec0d4f681519d8a81f8142cf64
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/278615
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 6d16234..f523e22 100644
--- a/internal/frontend/urlinfo.go
+++ b/internal/frontend/urlinfo.go
@@ -143,13 +143,19 @@
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" {
- return len(parts) >= 3 && parts[1] == "x"
+ if len(parts) < 2 {
+ return false
+ }
+ switch parts[1] {
+ case "dl":
+ return true
+ case "x":
+ return len(parts) >= 3
+ default:
+ return false
+ }
}
if vcsHostsWithThreeElementRepoName[parts[0]] && len(parts) < 3 {
return false
diff --git a/internal/frontend/urlinfo_test.go b/internal/frontend/urlinfo_test.go
index 11c886a..a93a5e9 100644
--- a/internal/frontend/urlinfo_test.go
+++ b/internal/frontend/urlinfo_test.go
@@ -192,6 +192,7 @@
{"github.com/foo/bar", true},
{"github.com/foo/bar/baz", true},
{"golang.org/dl", true},
+ {"golang.org/dl/go1.2.3", true},
{"golang.org/x", false},
{"golang.org/x/tools", true},
{"golang.org/x/tools/go/packages", true},