Skip to content

Commit

Permalink
Merge pull request #66 from andrewjanssen/fix-regex-exception
Browse files Browse the repository at this point in the history
Search fails on invalid regex
  • Loading branch information
Abdenasser authored Nov 8, 2024
2 parents d53a2b4 + 0eee4df commit 01bda83
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
Search for processes by name, command, or PID. Search for multiple things at once by separating them with commas. For
example, `arm, x86` will return processes having `arm` or `x86` as a substring of the name or command. You can use
regular expressions too. For example, `d$` will return a list of daemons (which tend to end in the letter `d`), while
`(\w+)\.\w+` will return a list of processes with reverse domain name notation, such as `com.docker.vmnetd`.
`^(\w+\.)+\w+$` will return a list of processes with reverse domain name notation, such as `com.docker.vmnetd`.

- 📌 Pin important processes
- 🛠 Process management (kill processes)
Expand Down
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 01bda83

Please sign in to comment.