mirror of
https://github.com/golang/go
synced 2024-11-18 15:24:41 -07:00
godoc: don't drop the query params when redirecting
http://golang.org/issue/new?title=Title was being redirected to https://github.com/golang/go/issues/new. The CL preserves the query parameters during direct. Change-Id: I3057ccd5304b00df53b664b71ea35ea05d313aa4 Reviewed-on: https://go-review.googlesource.com/15431 Reviewed-by: Andrew Gerrand <adg@golang.org>
This commit is contained in:
parent
365aedefa0
commit
f247eeaee6
@ -142,7 +142,11 @@ var prefixHelpers = map[string]string{
|
||||
|
||||
func Handler(target string) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, target, http.StatusMovedPermanently)
|
||||
url := target
|
||||
if qs := r.URL.RawQuery; qs != "" {
|
||||
url += "?" + qs
|
||||
}
|
||||
http.Redirect(w, r, url, http.StatusMovedPermanently)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -40,13 +40,15 @@ func TestRedirects(t *testing.T) {
|
||||
"/change": {301, "https://go.googlesource.com/go"},
|
||||
"/change/a": {302, "https://go.googlesource.com/go/+/a"},
|
||||
|
||||
"/issue": {301, "https://github.com/golang/go/issues"},
|
||||
"/issues": {301, "https://github.com/golang/go/issues"},
|
||||
"/issue/1": {302, "https://github.com/golang/go/issues/1"},
|
||||
"/issues/1": {302, "https://github.com/golang/go/issues/1"},
|
||||
"/issue/new": {301, "https://github.com/golang/go/issues/new"},
|
||||
"/issues/new": {301, "https://github.com/golang/go/issues/new"},
|
||||
"/issues/1/2/3": errorResult(404),
|
||||
"/issue": {301, "https://github.com/golang/go/issues"},
|
||||
"/issue?": {301, "https://github.com/golang/go/issues"},
|
||||
"/issue/1": {302, "https://github.com/golang/go/issues/1"},
|
||||
"/issue/new": {301, "https://github.com/golang/go/issues/new"},
|
||||
"/issue/new?a=b&c=d%20&e=f": {301, "https://github.com/golang/go/issues/new?a=b&c=d%20&e=f"},
|
||||
"/issues": {301, "https://github.com/golang/go/issues"},
|
||||
"/issues/1": {302, "https://github.com/golang/go/issues/1"},
|
||||
"/issues/new": {301, "https://github.com/golang/go/issues/new"},
|
||||
"/issues/1/2/3": errorResult(404),
|
||||
|
||||
"/design": {301, "https://github.com/golang/proposal/tree/master/design"},
|
||||
"/design/": {302, "/design"},
|
||||
|
Loading…
Reference in New Issue
Block a user