Commit c2aee3c0 authored by Shenghou Ma's avatar Shenghou Ma

cmd/godoc: when redirecting don't clear query string

so that http://golang.org/pkg/runtime?m=all works.

R=bradfitz
CC=golang-dev
https://golang.org/cl/7094046
parent 40b37588
...@@ -656,7 +656,9 @@ func redirect(w http.ResponseWriter, r *http.Request) (redirected bool) { ...@@ -656,7 +656,9 @@ func redirect(w http.ResponseWriter, r *http.Request) (redirected bool) {
canonical += "/" canonical += "/"
} }
if r.URL.Path != canonical { if r.URL.Path != canonical {
http.Redirect(w, r, canonical, http.StatusMovedPermanently) url := *r.URL
url.Path = canonical
http.Redirect(w, r, url.String(), http.StatusMovedPermanently)
redirected = true redirected = true
} }
return return
...@@ -668,7 +670,9 @@ func redirectFile(w http.ResponseWriter, r *http.Request) (redirected bool) { ...@@ -668,7 +670,9 @@ func redirectFile(w http.ResponseWriter, r *http.Request) (redirected bool) {
c = c[:len(c)-1] c = c[:len(c)-1]
} }
if r.URL.Path != c { if r.URL.Path != c {
http.Redirect(w, r, c, http.StatusMovedPermanently) url := *r.URL
url.Path = c
http.Redirect(w, r, url.String(), http.StatusMovedPermanently)
redirected = true redirected = true
} }
return return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment