cmd/golangorg: redirect /x/ to pkgsite subrepo page
For golang/go#47281 Change-Id: I065e6cb1d301701304228a3e4f263f3e576f8cbe Reviewed-on: https://go-review.googlesource.com/c/website/+/355809 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Jamal Carvalho <jamal@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Jamal Carvalho <jamal@golang.org>
This commit is contained in:
Родитель
2795752c7d
Коммит
7f7afedada
|
@ -491,7 +491,7 @@ func loggingHandler(h http.Handler) http.Handler {
|
|||
func xHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if !strings.HasPrefix(r.URL.Path, "/x/") {
|
||||
// Shouldn't happen if handler is registered correctly.
|
||||
http.Redirect(w, r, "https://pkg.go.dev/search?q=golang.org/x", http.StatusTemporaryRedirect)
|
||||
http.Redirect(w, r, "https://pkg.go.dev/golang.org/x", http.StatusTemporaryRedirect)
|
||||
return
|
||||
}
|
||||
proj, suffix := strings.TrimPrefix(r.URL.Path, "/x/"), ""
|
||||
|
@ -499,7 +499,7 @@ func xHandler(w http.ResponseWriter, r *http.Request) {
|
|||
proj, suffix = proj[:i], proj[i:]
|
||||
}
|
||||
if proj == "" {
|
||||
http.Redirect(w, r, "https://pkg.go.dev/search?q=golang.org/x", http.StatusTemporaryRedirect)
|
||||
http.Redirect(w, r, "https://pkg.go.dev/golang.org/x", http.StatusTemporaryRedirect)
|
||||
return
|
||||
}
|
||||
repo, ok := repos.ByGerritProject[proj]
|
||||
|
|
|
@ -19,7 +19,7 @@ code == 404
|
|||
|
||||
GET https://golang.org/x/
|
||||
code == 307
|
||||
header location == https://pkg.go.dev/search?q=golang.org/x
|
||||
header location == https://pkg.go.dev/golang.org/x
|
||||
|
||||
GET https://golang.org/x/In%20Valid,X
|
||||
code == 404
|
||||
|
|
Загрузка…
Ссылка в новой задаче