Skip to content

Commit

Permalink
feat: fuzzyMatch ignore case
Browse files Browse the repository at this point in the history
  • Loading branch information
zhzLuke96 committed Dec 26, 2024
1 parent 6e88205 commit af5e7f7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ function escapeRegExp(str: string) {
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}

function fuzzyMatch(pattern: string, str: string) {
function fuzzyMatch(pattern: string, text: string) {
// NOTE: ignore case
pattern = pattern.toLowerCase();
text = text.toLowerCase();

pattern =
".*" +
pattern
Expand All @@ -42,7 +46,7 @@ function fuzzyMatch(pattern: string, str: string) {
.map((l: string) => `${escapeRegExp(l)}.*`)
.join("");
const re = new RegExp(pattern);
return re.test(str);
return re.test(text);
}

// 通用类型定义
Expand Down

0 comments on commit af5e7f7

Please sign in to comment.