mirror of
https://github.com/golang/go
synced 2024-11-21 23:54:40 -07:00
godoc: fix absolute->relative mapping
Fixes #3096. R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/5690063
This commit is contained in:
parent
8542dc0764
commit
7b22e46282
@ -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 '/'
|
||||
|
Loading…
Reference in New Issue
Block a user