Skip to content

Commit af5e7f7

Browse files
committed
feat: fuzzyMatch ignore case
1 parent 6e88205 commit af5e7f7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/App.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ function escapeRegExp(str: string) {
3232
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3333
}
3434

35-
function fuzzyMatch(pattern: string, str: string) {
35+
function fuzzyMatch(pattern: string, text: string) {
36+
// NOTE: ignore case
37+
pattern = pattern.toLowerCase();
38+
text = text.toLowerCase();
39+
3640
pattern =
3741
".*" +
3842
pattern
@@ -42,7 +46,7 @@ function fuzzyMatch(pattern: string, str: string) {
4246
.map((l: string) => `${escapeRegExp(l)}.*`)
4347
.join("");
4448
const re = new RegExp(pattern);
45-
return re.test(str);
49+
return re.test(text);
4650
}
4751

4852
// 通用类型定义

0 commit comments

Comments
 (0)