mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-25 21:26:40 +00:00
don't catch mentions within links (#257)
This commit is contained in:
parent
0cd2bd2960
commit
28b6ce59d6
|
@ -52,8 +52,8 @@
|
||||||
// such as @whatever_user@example.org, returning whatever_user and example.org (without the @ symbols)
|
// such as @whatever_user@example.org, returning whatever_user and example.org (without the @ symbols)
|
||||||
MentionName = regexp.MustCompile(mentionName)
|
MentionName = regexp.MustCompile(mentionName)
|
||||||
|
|
||||||
// mention regex can be played around with here: https://regex101.com/r/qwM9D3/1
|
// mention regex can be played around with here: https://regex101.com/r/G1oGR0/1
|
||||||
mentionFinder = `(?:\B)(@\w+(?:@[a-zA-Z0-9_\-\.]+)?)(?:\B)?`
|
mentionFinder = `(?:^|\s)(@\w+(?:@[a-zA-Z0-9_\-\.]+)?)`
|
||||||
// MentionFinder extracts mentions from a piece of text.
|
// MentionFinder extracts mentions from a piece of text.
|
||||||
MentionFinder = regexp.MustCompile(mentionFinder)
|
MentionFinder = regexp.MustCompile(mentionFinder)
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,17 @@ type StatusTestSuite struct {
|
||||||
suite.Suite
|
suite.Suite
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *StatusTestSuite) TestLinkNoMention() {
|
||||||
|
statusText := `here's a link to a post by zork:
|
||||||
|
|
||||||
|
https://localhost:8080/@the_mighty_zork/statuses/01FGVP55XMF2K6316MQRX6PFG1
|
||||||
|
|
||||||
|
that link shouldn't come out formatted as a mention!`
|
||||||
|
|
||||||
|
menchies := util.DeriveMentionsFromText(statusText)
|
||||||
|
suite.Empty(menchies)
|
||||||
|
}
|
||||||
|
|
||||||
func (suite *StatusTestSuite) TestDeriveMentionsOK() {
|
func (suite *StatusTestSuite) TestDeriveMentionsOK() {
|
||||||
statusText := `@dumpsterqueer@example.org testing testing
|
statusText := `@dumpsterqueer@example.org testing testing
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue