@@ -76,7 +76,7 @@ func IsReadmeFile(name string) bool {
76
76
77
77
var (
78
78
// MentionPattern matches string that mentions someone, e.g. @Unknwon
79
- MentionPattern = regexp .MustCompile (`(\s|^)@[0-9a-zA-Z-_\.]+` )
79
+ MentionPattern = regexp .MustCompile (`(\s|^|\W )@[0-9a-zA-Z-_\.]+` )
80
80
81
81
// CommitPattern matches link to certain commit with or without trailing hash,
82
82
// e.g. https://try.gogs.io/gogs/gogs/commit/d8a994ef243349f321568f9e36d5c3f444b99cae#diff-2
@@ -101,7 +101,7 @@ var (
101
101
func FindAllMentions (content string ) []string {
102
102
mentions := MentionPattern .FindAllString (content , - 1 )
103
103
for i := range mentions {
104
- mentions [i ] = strings .TrimSpace (mentions [i ])[ 1 :] // Strip @ character
104
+ mentions [i ] = mentions [ i ][ strings .Index (mentions [i ], "@" ) + 1 :] // Strip @ character
105
105
}
106
106
return mentions
107
107
}
@@ -275,7 +275,7 @@ func RenderSha1CurrentPattern(rawBytes []byte, urlPrefix string) []byte {
275
275
func RenderSpecialLink (rawBytes []byte , urlPrefix string , metas map [string ]string ) []byte {
276
276
ms := MentionPattern .FindAll (rawBytes , - 1 )
277
277
for _ , m := range ms {
278
- m = bytes .TrimSpace ( m )
278
+ m = m [ bytes .Index ( m , [] byte ( "@" )):]
279
279
rawBytes = bytes .Replace (rawBytes , m ,
280
280
[]byte (fmt .Sprintf (`<a href="%s/%s">%s</a>` , setting .AppSubUrl , m [1 :], m )), - 1 )
281
281
}
0 commit comments