diff options
author | 2021-09-01 18:29:25 +0200 | |
---|---|---|
committer | 2021-09-01 18:29:25 +0200 | |
commit | 4696e1a7b389599fa981f334b343daa911b11f5d (patch) | |
tree | d1ca0c896cdacb82ad7c64ee150aa32b37d4c053 /internal/util/statustools.go | |
parent | move oauth models into gtsmodel (diff) | |
download | gotosocial-4696e1a7b389599fa981f334b343daa911b11f5d.tar.xz |
moving stuff around
Diffstat (limited to 'internal/util/statustools.go')
-rw-r--r-- | internal/util/statustools.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/internal/util/statustools.go b/internal/util/statustools.go index 4a89e60f6..ca18577b0 100644 --- a/internal/util/statustools.go +++ b/internal/util/statustools.go @@ -21,6 +21,8 @@ package util import ( "fmt" "strings" + + "github.com/superseriousbusiness/gotosocial/internal/regexes" ) // DeriveMentionsFromStatus takes a plaintext (ie., not html-formatted) status, @@ -31,7 +33,7 @@ import ( // or the form "@username" for local users. func DeriveMentionsFromStatus(status string) []string { mentionedAccounts := []string{} - for _, m := range mentionFinderRegex.FindAllStringSubmatch(status, -1) { + for _, m := range regexes.MentionFinder.FindAllStringSubmatch(status, -1) { mentionedAccounts = append(mentionedAccounts, m[1]) } return UniqueStrings(mentionedAccounts) @@ -43,7 +45,7 @@ func DeriveMentionsFromStatus(status string) []string { // tags will be lowered, for consistency. func DeriveHashtagsFromStatus(status string) []string { tags := []string{} - for _, m := range HashtagFinderRegex.FindAllStringSubmatch(status, -1) { + for _, m := range regexes.HashtagFinder.FindAllStringSubmatch(status, -1) { tags = append(tags, strings.TrimPrefix(m[1], "#")) } return UniqueStrings(tags) @@ -54,7 +56,7 @@ func DeriveHashtagsFromStatus(status string) []string { // used in that status, without the surround ::. func DeriveEmojisFromStatus(status string) []string { emojis := []string{} - for _, m := range emojiFinderRegex.FindAllStringSubmatch(status, -1) { + for _, m := range regexes.EmojiFinder.FindAllStringSubmatch(status, -1) { emojis = append(emojis, m[1]) } return UniqueStrings(emojis) @@ -65,7 +67,7 @@ func DeriveEmojisFromStatus(status string) []string { // // If nothing is matched, it will return an error. func ExtractMentionParts(mention string) (username, domain string, err error) { - matches := mentionNameRegex.FindStringSubmatch(mention) + matches := regexes.MentionName.FindStringSubmatch(mention) if matches == nil || len(matches) != 3 { err = fmt.Errorf("could't match mention %s", mention) return @@ -77,5 +79,5 @@ func ExtractMentionParts(mention string) (username, domain string, err error) { // IsMention returns true if the passed string looks like @whatever@example.org func IsMention(mention string) bool { - return mentionNameRegex.MatchString(strings.ToLower(mention)) + return regexes.MentionName.MatchString(strings.ToLower(mention)) } |