gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 28b6ce59d6e19603605f259317a9387db15505bb
parent 0cd2bd2960e29a3e8c39de543f7e9a8d635e2221
Author: tobi <31960611+tsmethurst@users.noreply.github.com>
Date:   Thu, 30 Sep 2021 18:11:57 +0200

don't catch mentions within links (#257)


Diffstat:
Minternal/regexes/regexes.go | 4++--
Minternal/util/statustools_test.go | 11+++++++++++
2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/internal/regexes/regexes.go b/internal/regexes/regexes.go @@ -52,8 +52,8 @@ var ( // such as @whatever_user@example.org, returning whatever_user and example.org (without the @ symbols) MentionName = regexp.MustCompile(mentionName) - // mention regex can be played around with here: https://regex101.com/r/qwM9D3/1 - mentionFinder = `(?:\B)(@\w+(?:@[a-zA-Z0-9_\-\.]+)?)(?:\B)?` + // mention regex can be played around with here: https://regex101.com/r/G1oGR0/1 + mentionFinder = `(?:^|\s)(@\w+(?:@[a-zA-Z0-9_\-\.]+)?)` // MentionFinder extracts mentions from a piece of text. MentionFinder = regexp.MustCompile(mentionFinder) diff --git a/internal/util/statustools_test.go b/internal/util/statustools_test.go @@ -30,6 +30,17 @@ type StatusTestSuite struct { 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() { statusText := `@dumpsterqueer@example.org testing testing