Skip to content

Commit

Permalink
Fix: exception when search term is not a valid regex
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjanssen committed Nov 8, 2024
1 parent 5082a50 commit 8a04f30
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@
const nameSubstringMatch = process.name
.toLowerCase()
.includes(term.toLowerCase());
const nameRegexMatch = new RegExp(term, "i").test(process.name);
const nameRegexMatch = (() => {
try {
return new RegExp(term, "i").test(process.name);
} catch {
return false;
}
})();
const commandMatch = process.command
.toLowerCase()
.includes(term.toLowerCase());
Expand Down

0 comments on commit 8a04f30

Please sign in to comment.