diff options
| author | Jonathan Amsterdam <jba@google.com> | 2019-10-17 11:20:02 -0400 |
|---|---|---|
| committer | Julie Qiu <julie@golang.org> | 2020-03-27 16:46:45 -0400 |
| commit | dfd2bbc52f8ee4437ad07e6cf5b6bf0cf755b3bb (patch) | |
| tree | 5b0077e5b057743207faf625dcec9222cb797067 /internal/source/source.go | |
| parent | 0f82af2fee2a4b85be021ab11fad83ba509084ad (diff) | |
| download | go-x-pkgsite-dfd2bbc52f8ee4437ad07e6cf5b6bf0cf755b3bb.tar.xz | |
internal/frontend: translate relative non-image links in readmes
If a Readme has a relative link that is not an image, convert
it to an absolute link to the file using source info.
Fixes b/140250096.
Change-Id: I9ca629963ca87d7605c0217e49671b33c7dd0f86
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/576296
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Diffstat (limited to 'internal/source/source.go')
| -rw-r--r-- | internal/source/source.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/internal/source/source.go b/internal/source/source.go index fa4dc551..289ffb6d 100644 --- a/internal/source/source.go +++ b/internal/source/source.go @@ -63,6 +63,9 @@ func (i *Info) ModuleURL() string { // DirectoryURL returns a URL for a directory relative to the module's home directory. func (i *Info) DirectoryURL(dir string) string { + if i == nil { + return "" + } return strings.TrimSuffix(expand(i.templates.Directory, map[string]string{ "repo": i.repoURL, "commit": i.commit, @@ -72,6 +75,9 @@ func (i *Info) DirectoryURL(dir string) string { // FileURL returns a URL for a file whose pathname is relative to the module's home directory. func (i *Info) FileURL(pathname string) string { + if i == nil { + return "" + } return expand(i.templates.File, map[string]string{ "repo": i.repoURL, "commit": i.commit, @@ -81,6 +87,9 @@ func (i *Info) FileURL(pathname string) string { // LineURL returns a URL referring to a line in a file relative to the module's home directory. func (i *Info) LineURL(pathname string, line int) string { + if i == nil { + return "" + } return expand(i.templates.Line, map[string]string{ "repo": i.repoURL, "commit": i.commit, |
