Skip to content

Commit a0c397d

Browse files
authored
Recognize more characters in crossreferenced repo name (#3413)
1 parent 9e87fe8 commit a0c397d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

modules/markup/html.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var (
4343
IssueAlphanumericPattern = regexp.MustCompile(`( |^|\()[A-Z]{1,10}-[1-9][0-9]*\b`)
4444
// CrossReferenceIssueNumericPattern matches string that references a numeric issue in a different repository
4545
// e.g. gogits/gogs#12345
46-
CrossReferenceIssueNumericPattern = regexp.MustCompile(`( |^)[0-9a-zA-Z]+/[0-9a-zA-Z]+#[0-9]+\b`)
46+
CrossReferenceIssueNumericPattern = regexp.MustCompile(`( |^)[0-9a-zA-Z-_\.]+/[0-9a-zA-Z-_\.]+#[0-9]+\b`)
4747

4848
// Sha1CurrentPattern matches string that represents a commit SHA, e.g. d8a994ef243349f321568f9e36d5c3f444b99cae
4949
// Although SHA1 hashes are 40 chars long, the regex matches the hash from 7 to 40 chars in length

modules/markup/html_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ func TestRender_CrossReferences(t *testing.T) {
285285
test(
286286
"gogits/gogs#12345",
287287
`<p><a href="`+URLJoin(AppURL, "gogits", "gogs", "issues", "12345")+`" rel="nofollow">gogits/gogs#12345</a></p>`)
288+
test(
289+
"go-gitea/gitea#12345",
290+
`<p><a href="`+URLJoin(AppURL, "go-gitea", "gitea", "issues", "12345")+`" rel="nofollow">go-gitea/gitea#12345</a></p>`)
288291
}
289292

290293
func TestRender_FullIssueURLs(t *testing.T) {

0 commit comments

Comments
 (0)