Skip to content

Commit

Permalink
No need to find multiple matches in the same string - fix test case t…
Browse files Browse the repository at this point in the history
…oo! Fixes #21
  • Loading branch information
Transfusion committed Mar 7, 2021
1 parent 5fee6eb commit 65203ff
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/searchalgo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const filterUsingIDCs = (
) => {
const idcs = _idcs.split("").filter((idc) => IDCSet.has(idc));
if (!idcs) return results;
const pattern = RegExp(idcs.join(".*"), "g");
const pattern = RegExp(idcs.join(".*"));
return results.filter((result) => {
for (let { i } of reverseMapIDSOnly[result]) {
if (pattern.test(i)) {
Expand Down
1 change: 1 addition & 0 deletions src/searchalgo/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ test("filterUsingIDCs", () => {
const results = ["與", "义", "凶", "出", "函", "半"];
expect(filterUsingIDCs(reverseMapCharIDSOnly, results, "⿶")).toEqual([
"與",
"义",
"凶",
"函",
]);
Expand Down

0 comments on commit 65203ff

Please sign in to comment.