summaryrefslogtreecommitdiff
path: root/internal/util
diff options
context:
space:
mode:
Diffstat (limited to 'internal/util')
-rw-r--r--internal/util/statustools.go24
-rw-r--r--internal/util/statustools_test.go14
2 files changed, 19 insertions, 19 deletions
diff --git a/internal/util/statustools.go b/internal/util/statustools.go
index ca18577b0..95ce63a5b 100644
--- a/internal/util/statustools.go
+++ b/internal/util/statustools.go
@@ -25,38 +25,38 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/regexes"
)
-// DeriveMentionsFromStatus takes a plaintext (ie., not html-formatted) status,
+// DeriveMentionsFromText takes a plaintext (ie., not html-formatted) text,
// and applies a regex to it to return a deduplicated list of accounts
-// mentioned in that status.
+// mentioned in that text.
//
// It will look for fully-qualified account names in the form "@user@example.org".
// or the form "@username" for local users.
-func DeriveMentionsFromStatus(status string) []string {
+func DeriveMentionsFromText(text string) []string {
mentionedAccounts := []string{}
- for _, m := range regexes.MentionFinder.FindAllStringSubmatch(status, -1) {
+ for _, m := range regexes.MentionFinder.FindAllStringSubmatch(text, -1) {
mentionedAccounts = append(mentionedAccounts, m[1])
}
return UniqueStrings(mentionedAccounts)
}
-// DeriveHashtagsFromStatus takes a plaintext (ie., not html-formatted) status,
+// DeriveHashtagsFromText takes a plaintext (ie., not html-formatted) text,
// and applies a regex to it to return a deduplicated list of hashtags
-// used in that status, without the leading #. The case of the returned
+// used in that text, without the leading #. The case of the returned
// tags will be lowered, for consistency.
-func DeriveHashtagsFromStatus(status string) []string {
+func DeriveHashtagsFromText(text string) []string {
tags := []string{}
- for _, m := range regexes.HashtagFinder.FindAllStringSubmatch(status, -1) {
+ for _, m := range regexes.HashtagFinder.FindAllStringSubmatch(text, -1) {
tags = append(tags, strings.TrimPrefix(m[1], "#"))
}
return UniqueStrings(tags)
}
-// DeriveEmojisFromStatus takes a plaintext (ie., not html-formatted) status,
+// DeriveEmojisFromText takes a plaintext (ie., not html-formatted) text,
// and applies a regex to it to return a deduplicated list of emojis
-// used in that status, without the surround ::.
-func DeriveEmojisFromStatus(status string) []string {
+// used in that text, without the surrounding `::`
+func DeriveEmojisFromText(text string) []string {
emojis := []string{}
- for _, m := range regexes.EmojiFinder.FindAllStringSubmatch(status, -1) {
+ for _, m := range regexes.EmojiFinder.FindAllStringSubmatch(text, -1) {
emojis = append(emojis, m[1])
}
return UniqueStrings(emojis)
diff --git a/internal/util/statustools_test.go b/internal/util/statustools_test.go
index 0ec2719f5..447315b25 100644
--- a/internal/util/statustools_test.go
+++ b/internal/util/statustools_test.go
@@ -45,7 +45,7 @@ func (suite *StatusTestSuite) TestDeriveMentionsOK() {
`
- menchies := util.DeriveMentionsFromStatus(statusText)
+ menchies := util.DeriveMentionsFromText(statusText)
assert.Len(suite.T(), menchies, 6)
assert.Equal(suite.T(), "@dumpsterqueer@example.org", menchies[0])
assert.Equal(suite.T(), "@someone_else@testing.best-horse.com", menchies[1])
@@ -57,7 +57,7 @@ func (suite *StatusTestSuite) TestDeriveMentionsOK() {
func (suite *StatusTestSuite) TestDeriveMentionsEmpty() {
statusText := ``
- menchies := util.DeriveMentionsFromStatus(statusText)
+ menchies := util.DeriveMentionsFromText(statusText)
assert.Len(suite.T(), menchies, 0)
}
@@ -74,7 +74,7 @@ func (suite *StatusTestSuite) TestDeriveHashtagsOK() {
#111111 thisalsoshouldn'twork#### ##`
- tags := util.DeriveHashtagsFromStatus(statusText)
+ tags := util.DeriveHashtagsFromText(statusText)
assert.Len(suite.T(), tags, 5)
assert.Equal(suite.T(), "testing123", tags[0])
assert.Equal(suite.T(), "also", tags[1])
@@ -97,7 +97,7 @@ Here's some normal text with an :emoji: at the end
:underscores_ok_too:
`
- tags := util.DeriveEmojisFromStatus(statusText)
+ tags := util.DeriveEmojisFromText(statusText)
assert.Len(suite.T(), tags, 7)
assert.Equal(suite.T(), "test", tags[0])
assert.Equal(suite.T(), "another", tags[1])
@@ -115,9 +115,9 @@ func (suite *StatusTestSuite) TestDeriveMultiple() {
Text`
- ms := util.DeriveMentionsFromStatus(statusText)
- hs := util.DeriveHashtagsFromStatus(statusText)
- es := util.DeriveEmojisFromStatus(statusText)
+ ms := util.DeriveMentionsFromText(statusText)
+ hs := util.DeriveHashtagsFromText(statusText)
+ es := util.DeriveEmojisFromText(statusText)
assert.Len(suite.T(), ms, 1)
assert.Equal(suite.T(), "@foss_satan@fossbros-anonymous.io", ms[0])