summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-11-15 17:37:26 -0500
committerUnknwon <u@gogs.io>2015-11-15 17:37:26 -0500
commit1a901433e2a27e5bcd29216fdb57082be620b745 (patch)
treede0a11256498653c850c2c33f571462da5da24c6 /modules
parente030109b5af9015c018cdc6f18655e201f6008bf (diff)
downloadgitea-1a901433e2a27e5bcd29216fdb57082be620b745.tar.gz
gitea-1a901433e2a27e5bcd29216fdb57082be620b745.zip
minor fix for #1949
Diffstat (limited to 'modules')
-rw-r--r--modules/base/markdown.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/modules/base/markdown.go b/modules/base/markdown.go
index 9d297f0ce8..1f48b88db7 100644
--- a/modules/base/markdown.go
+++ b/modules/base/markdown.go
@@ -167,10 +167,21 @@ func RenderSha1CurrentPattern(rawBytes []byte, urlPrefix string) []byte {
return rawBytes
}
-func RenderIssueIndexPattern(rawBytes []byte, urlPrefix string) []byte {
- if i := strings.Index(urlPrefix, "/src"); i != -1 {
- urlPrefix = urlPrefix[:i]
+func cutoutVerbosePrefix(prefix string) string {
+ count := 0
+ for i := 0; i < len(prefix); i++ {
+ if prefix[i] == '/' {
+ count++
+ }
+ if count >= 3 {
+ return prefix[:i]
+ }
}
+ return prefix
+}
+
+func RenderIssueIndexPattern(rawBytes []byte, urlPrefix string) []byte {
+ urlPrefix = cutoutVerbosePrefix(urlPrefix)
ms := issueIndexPattern.FindAll(rawBytes, -1)
for _, m := range ms {
var space string