Skip to content

Commit

Permalink
fix: dam should match string case insenstive
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Oct 7, 2024
1 parent 607d188 commit aa16d09
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions internal/pkg/dam/dam.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package dam

import (
"regexp"
"strings"
"unicode"

"github.com/trim21/errgo"
Expand All @@ -34,21 +33,21 @@ func New(c config.AppConfig) (Dam, error) {
var cc Dam
var err error
if c.NsfwWord != "" {
cc.nsfwWord, err = regexp.Compile(c.NsfwWord)
cc.nsfwWord, err = regexp.Compile("(?i)" + c.NsfwWord)
if err != nil {
return Dam{}, errgo.Wrap(err, "nsfw_word")
}
}

if c.DisableWords != "" {
cc.disableWord, err = regexp.Compile(c.DisableWords)
cc.disableWord, err = regexp.Compile("(?i)" + c.DisableWords)
if err != nil {
return Dam{}, errgo.Wrap(err, "disable_words")
}
}

if c.BannedDomain != "" {
cc.bannedDomain, err = regexp.Compile(c.BannedDomain)
cc.bannedDomain, err = regexp.Compile("(?i)" + c.BannedDomain)
if err != nil {
return Dam{}, errgo.Wrap(err, "banned_domain")
}
Expand All @@ -65,8 +64,6 @@ func (d Dam) NeedReview(text string) bool {
return false
}

text = strings.ToLower(text)

return d.disableWord.MatchString(text)
}

Expand Down

0 comments on commit aa16d09

Please sign in to comment.