From 85c58eba902b554822666acec78046379a17b598 Mon Sep 17 00:00:00 2001 From: Howl Date: Sun, 15 Nov 2015 12:04:43 +0100 Subject: [PATCH 1/2] Fix bad issue links in non-readme markdown files --- modules/base/markdown.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/base/markdown.go b/modules/base/markdown.go index 8f3d6bef1a19..70c2918af079 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -168,6 +168,9 @@ func RenderSha1CurrentPattern(rawBytes []byte, urlPrefix string) []byte { } func RenderIssueIndexPattern(rawBytes []byte, urlPrefix string) []byte { + // Remove unnecessary things after username and reponame in prefix + // (otherwise stuff like /:user/:repo/src/master/issues/1 would happen) + urlPrefix = strings.Join(strings.Split(urlPrefix, "/")[:3], "/") ms := issueIndexPattern.FindAll(rawBytes, -1) for _, m := range ms { var space string From ca5678da3268706b8516a52ef945742792c297a0 Mon Sep 17 00:00:00 2001 From: Howl Date: Sun, 15 Nov 2015 22:22:25 +0100 Subject: [PATCH 2/2] Safely detect urlPrefix in the format /:owner/:repo --- modules/base/markdown.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/base/markdown.go b/modules/base/markdown.go index 70c2918af079..9d297f0ce8bf 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -168,9 +168,9 @@ func RenderSha1CurrentPattern(rawBytes []byte, urlPrefix string) []byte { } func RenderIssueIndexPattern(rawBytes []byte, urlPrefix string) []byte { - // Remove unnecessary things after username and reponame in prefix - // (otherwise stuff like /:user/:repo/src/master/issues/1 would happen) - urlPrefix = strings.Join(strings.Split(urlPrefix, "/")[:3], "/") + if i := strings.Index(urlPrefix, "/src"); i != -1 { + urlPrefix = urlPrefix[:i] + } ms := issueIndexPattern.FindAll(rawBytes, -1) for _, m := range ms { var space string