From e83ad075b0abe711c766661c53bb889d75639e8a Mon Sep 17 00:00:00 2001 From: xxjwxc Date: Fri, 1 Apr 2022 16:59:26 +0800 Subject: [PATCH] 1 --- wordsfilter/node.go | 6 ++++-- wordsfilter/words_filter_test.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/wordsfilter/node.go b/wordsfilter/node.go index 92c6a39..dc6e2a7 100644 --- a/wordsfilter/node.go +++ b/wordsfilter/node.go @@ -152,8 +152,10 @@ func (node *Node) contains(text string, root map[string]*Node) bool { return true } point = n.Child - index = i - jump = true + if !jump { + index = i + jump = true + } } } else { if jump { diff --git a/wordsfilter/words_filter_test.go b/wordsfilter/words_filter_test.go index 513a91d..8c546a1 100644 --- a/wordsfilter/words_filter_test.go +++ b/wordsfilter/words_filter_test.go @@ -16,7 +16,7 @@ func TestWordsFilter(t *testing.T) { // wf.Placeholder = "" root := wf.Generate(texts) wf.Remove("shif", root) - c1 := wf.Contains("你爱液", root) // 是否有敏感词 + c1 := wf.Contains("你的爱液", root) // 是否有敏感词 if c1 != false { t.Errorf("Test Contains expect false, get %T, %v", c1, c1) }