mirror of
https://github.com/golang/go
synced 2024-11-20 05:24:41 -07:00
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
This commit is contained in:
parent
98155bd6a9
commit
849ad2d0ca
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user