From 7b22e4628296518691a8ce6e4e4065ff4aeb69d8 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 21 Feb 2012 18:12:37 -0800 Subject: [PATCH] godoc: fix absolute->relative mapping Fixes #3096. R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/5690063 --- src/cmd/godoc/mapping.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cmd/godoc/mapping.go b/src/cmd/godoc/mapping.go index 89e531e2f3d..1a0da15bfcd 100644 --- a/src/cmd/godoc/mapping.go +++ b/src/cmd/godoc/mapping.go @@ -178,7 +178,8 @@ func (m *Mapping) ToAbsolute(spath string) string { // func (m *Mapping) ToRelative(fpath string) string { for _, e := range m.list { - if strings.HasPrefix(fpath, e.path) { + // if fpath has prefix e.path, the next character must be a separator (was issue 3096) + if strings.HasPrefix(fpath, e.path) && fpath[len(e.path)] == filepath.Separator { spath := filepath.ToSlash(fpath) // /absolute/prefix/foo -> prefix/foo return path.Join(e.prefix, spath[len(e.path):]) // Join will remove a trailing '/'