mirror of
https://github.com/golang/go
synced 2024-11-13 17:50:23 -07:00
godoc: fix redirect loop for URL "/".
R=golang-dev, bradfitz, rsc, adg CC=golang-dev https://golang.org/cl/5606045
This commit is contained in:
parent
e280035fc1
commit
702151a200
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user