Fix WordFinder matching anything with empty BannedWords.txt (#1045)
This commit is contained in:
parent
1237276823
commit
6e42ed0da4
|
|
@ -27,6 +27,8 @@ class WordFinder
|
|||
//trim extraneous leading pipe (|)
|
||||
patternString = patternString.substring(1);
|
||||
}
|
||||
// No words are defined, match nothing.
|
||||
else return;
|
||||
|
||||
this.pattern = Pattern.compile(patternString, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package me.ryanhamshire.GriefPrevention;
|
|||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.UUID;
|
||||
|
|
@ -68,8 +67,10 @@ public class Tests
|
|||
@Test
|
||||
public void testWordFinderEmptyList()
|
||||
{
|
||||
WordFinder finder = new WordFinder(new ArrayList<>());
|
||||
WordFinder finder = new WordFinder(Collections.emptyList());
|
||||
assertFalse(finder.hasMatch("alpha"));
|
||||
finder = new WordFinder(Collections.singletonList(""));
|
||||
assertFalse(finder.hasMatch("beta"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user