Skip to content

Commit

Permalink
Merge pull request #25 from lumbric/patch-2
Browse files Browse the repository at this point in the history
 Fix regex to allow brackets, fixes #24
  • Loading branch information
coreyhulen committed Sep 10, 2018
2 parents 4933505 + 1c6d539 commit 5a6afd9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/autolinker.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewAutoLinker(link *Link) (*AutoLinker, error) {
}

if !link.DisableNonWordSuffix {
link.Pattern = link.Pattern + "(?P<DisableNonWordSuffix>$|\\s|\\.|\\!|\\?|\\,)"
link.Pattern = link.Pattern + "(?P<DisableNonWordSuffix>$|\\s|\\.|\\!|\\?|\\,|\\))"
link.Template = link.Template + "${DisableNonWordSuffix}"
}

Expand Down
16 changes: 16 additions & 0 deletions server/autolinker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ func TestAutolink(t *testing.T) {
"Welcome MM-12345 should link!",
"Welcome [MM-12345](https://mattermost.atlassian.net/browse/MM-12345) should link!",
},
{
&Link{
Pattern: "(MM)(-)(?P<jira_id>\\d+)",
Template: "[MM-$jira_id](https://mattermost.atlassian.net/browse/MM-$jira_id)",
},
"Link in brackets should link (see MM-12345)",
"Link in brackets should link (see [MM-12345](https://mattermost.atlassian.net/browse/MM-12345))",
},
{
&Link{
Pattern: "(MM)(-)(?P<jira_id>\\d+)",
Template: "[MM-$jira_id](https://mattermost.atlassian.net/browse/MM-$jira_id)",
},
"Link a ticket MM-12345, before a comma",
"Link a ticket [MM-12345](https://mattermost.atlassian.net/browse/MM-12345), before a comma",
},
{
&Link{
Pattern: "(MM)(-)(?P<jira_id>\\d+)",
Expand Down

0 comments on commit 5a6afd9

Please sign in to comment.