diff options
author | 2021-08-11 16:54:54 +0200 | |
---|---|---|
committer | 2021-08-11 16:54:54 +0200 | |
commit | 329a5e8144eea78e607c8a218ae78ae8f346f2e8 (patch) | |
tree | 73072075ad682212d77504d4199ae756f4950a60 /internal/util/statustools.go | |
parent | ahhh (diff) | |
download | gotosocial-329a5e8144eea78e607c8a218ae78ae8f346f2e8.tar.xz |
Text duplication fix (#137)
* start testing text duplication
* tests
* fixes + tests
Diffstat (limited to 'internal/util/statustools.go')
-rw-r--r-- | internal/util/statustools.go | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/internal/util/statustools.go b/internal/util/statustools.go index 93294da68..ce5860c6d 100644 --- a/internal/util/statustools.go +++ b/internal/util/statustools.go @@ -46,7 +46,7 @@ func DeriveHashtagsFromStatus(status string) []string { for _, m := range HashtagFinderRegex.FindAllStringSubmatch(status, -1) { tags = append(tags, strings.TrimPrefix(m[1], "#")) } - return uniqueLower(tags) + return unique(tags) } // DeriveEmojisFromStatus takes a plaintext (ie., not html-formatted) status, @@ -92,17 +92,3 @@ func unique(s []string) []string { } return list } - -// uniqueLower returns a deduplicated version of a given string slice, with all entries converted to lowercase -func uniqueLower(s []string) []string { - keys := make(map[string]bool) - list := []string{} - for _, entry := range s { - eLower := strings.ToLower(entry) - if _, value := keys[eLower]; !value { - keys[eLower] = true - list = append(list, eLower) - } - } - return list -} |