Commit 702151a2 authored by Sameer Ajmani's avatar Sameer Ajmani

godoc: fix redirect loop for URL "/".

R=golang-dev, bradfitz, rsc, adg
CC=golang-dev
https://golang.org/cl/5606045
parent e280035f
......@@ -743,7 +743,11 @@ func applyTemplate(t *template.Template, name string, data interface{}) []byte {
}
func redirect(w http.ResponseWriter, r *http.Request) (redirected bool) {
if canonical := path.Clean(r.URL.Path) + "/"; r.URL.Path != canonical {
canonical := path.Clean(r.URL.Path)
if !strings.HasSuffix("/", canonical) {
canonical += "/"
}
if r.URL.Path != canonical {
http.Redirect(w, r, canonical, http.StatusMovedPermanently)
redirected = true
}
......
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