Looly 6 年之前
父节点
当前提交
314cb1b64c

+ 1 - 1
CHANGELOG.md

@@ -9,4 +9,4 @@
 * 【all】        升级JDK最低支持到8
 
 ### Bug修复
-* 【http】       修复Cookie中host失效导致的问题
+* 【http】       修复Cookie中host失效导致的问题(issue#583@Github)

+ 5 - 5
hutool-dfa/src/main/java/cn/hutool/dfa/WordTree.java

@@ -160,7 +160,7 @@ public class WordTree extends HashMap<Character, WordTree>{
 			return null;
 		}
 		
-		List<String> findedWords = new ArrayList<String>();
+		List<String> foundWords = new ArrayList<>();
 		WordTree current = this;
 		int length = text.length();
 		//存放查找到的字符缓存。完整出现一个词时加到findedWords中,否则清空
@@ -187,10 +187,10 @@ public class WordTree extends HashMap<Character, WordTree>{
 				wordBuffer.append(currentChar);
 				if(current.isEnd(currentChar)){
 					//到达单词末尾,关键词成立,从此词的下一个位置开始查找
-					findedWords.add(wordBuffer.toString());
-					if(limit > 0 && findedWords.size() >= limit){
+					foundWords.add(wordBuffer.toString());
+					if(limit > 0 && foundWords.size() >= limit){
 						//超过匹配限制个数,直接返回
-						return findedWords;
+						return foundWords;
 					}
 					if(false == isDensityMatch){
 						//如果非密度匹配,跳过匹配到的词
@@ -208,7 +208,7 @@ public class WordTree extends HashMap<Character, WordTree>{
 			}
 			current = this;
 		}
-		return findedWords;
+		return foundWords;
 	}
 	
 	

+ 9 - 0
hutool-dfa/src/test/java/cn/hutool/dfa/test/DfaTest.java

@@ -93,6 +93,15 @@ public class DfaTest {
 		List<String> all = tree.matchAll("AAAAAAAt-ioBBBBBBB");
 		Assert.assertEquals(all, CollectionUtil.newArrayList("t-io"));
 	}
+
+	@Test
+	public void aTest(){
+		WordTree tree = new WordTree();
+		tree.addWord("women");
+		String text = "a WOMEN todo.".toLowerCase();
+		List<String> matchAll = tree.matchAll(text, -1, false, false);
+		Assert.assertEquals("[women]", matchAll.toString());
+	}
 	
 	// ----------------------------------------------------------------------------------------------------------
 	/**