internal/frontend: enable requests to std@master
Requests to pkg.go.dev/std@master are now supported.
For golang/go#44390
Change-Id: Ie64ea679bfe855aa690004bf6effd7be424aa5dc
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/294832
Trust: Julie Qiu <julie@golang.org>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
diff --git a/internal/frontend/urlinfo.go b/internal/frontend/urlinfo.go
index f523e22..9737184 100644
--- a/internal/frontend/urlinfo.go
+++ b/internal/frontend/urlinfo.go
@@ -182,7 +182,7 @@
// isSupportedVersion reports whether the version is supported by the frontend.
func isSupportedVersion(fullPath, requestedVersion string) bool {
if _, ok := internal.DefaultBranches[requestedVersion]; ok {
- return !stdlib.Contains(fullPath)
+ return !stdlib.Contains(fullPath) || requestedVersion == "master"
}
return requestedVersion == internal.LatestVersion || semver.IsValid(requestedVersion)
}
diff --git a/internal/frontend/urlinfo_test.go b/internal/frontend/urlinfo_test.go
index a93a5e9..d876db8 100644
--- a/internal/frontend/urlinfo_test.go
+++ b/internal/frontend/urlinfo_test.go
@@ -218,7 +218,7 @@
{"net/http", "v1.2.3", true}, // isSupportedVersion expects the goTag is already converted to semver
{"net/http", "v1.2.3.bad", false},
{"net/http", "latest", true},
- {"net/http", "master", false},
+ {"net/http", "master", true},
{"net/http", "main", false},
}
for _, test := range tests {
diff --git a/internal/frontend/versions.go b/internal/frontend/versions.go
index 29da4d5..8fe7e7f 100644
--- a/internal/frontend/versions.go
+++ b/internal/frontend/versions.go
@@ -276,6 +276,9 @@
// displayVersion returns the version string, formatted for display.
func displayVersion(v string, modulePath string) string {
if modulePath == stdlib.ModulePath {
+ if strings.HasPrefix(v, "v0.0.0") {
+ return strings.Split(v, "-")[2]
+ }
return goTagForVersion(v)
}
return formatVersion(v)