Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(internal/godocfx): prevent index out of bounds when pkg == mod (#…
  • Loading branch information
tbpg committed Mar 3, 2021
1 parent 77f76ed commit 3d80b4e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/godocfx/parse.go
Expand Up @@ -461,7 +461,10 @@ func (l *linker) toURL(pkg, name string) string {
return fmt.Sprintf("#%s", name)
}
if mod, ok := l.sameDomainModules[pkg]; ok {
pkgRemainder := pkg[len(mod.Path)+1:] // +1 to skip slash.
pkgRemainder := ""
if pkg != mod.Path {
pkgRemainder = pkg[len(mod.Path)+1:] // +1 to skip slash.
}
// Note: we always link to latest. One day, we'll link to mod.Version.
baseURL := fmt.Sprintf("/go/docs/reference/%v/latest/%v", mod.Path, pkgRemainder)
if anchor := l.idToAnchor[pkg][name]; anchor != "" {
Expand Down

0 comments on commit 3d80b4e

Please sign in to comment.