Commit 849ad2d0 authored by Andrew Gerrand's avatar Andrew Gerrand

cmd/godoc: canonicalize custom path redirects

For example, /ref and /doc/reference.html now both redirect to /ref/.

Fixes #3401.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5916044
parent 98155bd6
......@@ -1315,7 +1315,18 @@ func refreshMetadataLoop() {
//
func metadataFor(relpath string) *Metadata {
if m, _ := docMetadata.get(); m != nil {
return m.(map[string]*Metadata)[relpath]
meta := m.(map[string]*Metadata)
// If metadata for this relpath exists, return it.
if p := meta[relpath]; p != nil {
return p
}
// Try with or without trailing slash.
if strings.HasSuffix(relpath, "/") {
relpath = relpath[:len(relpath)-1]
} else {
relpath = relpath + "/"
}
return meta[relpath]
}
return nil
}
......
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