feat(monitors search): Use regex instead of `LowerCase`

Except with less than 20 monitors, regex seems faster.
pull/5438/head
Ionys 3 weeks ago
parent c486e5bff9
commit 1e0342949f

@ -324,14 +324,14 @@ export default {
// finds monitor name, tag name or tag value // finds monitor name, tag name or tag value
let searchTextMatch = true; let searchTextMatch = true;
if (this.searchText !== "") { if (this.searchText !== "") {
const loweredSearchText = this.searchText.toLowerCase(); const regex = new RegExp(this.searchText, "i");
searchTextMatch = searchTextMatch =
monitor.name.toLowerCase().includes(loweredSearchText) regex.test(monitor.name) ||
|| monitor.url?.toLowerCase().includes(loweredSearchText) regex.test(monitor.url) ||
|| monitor.hostname?.toLowerCase().includes(loweredSearchText) regex.test(monitor.hostname) ||
|| monitor.dns_resolve_server?.toLowerCase().includes(loweredSearchText) regex.test(monitor.dns_resolve_server) ||
|| monitor.tags.find(tag => tag.name.toLowerCase().includes(loweredSearchText) monitor.tags.find((tag) => regex.test(tag.name) || regex.test(tag.value));
|| tag.value?.toLowerCase().includes(loweredSearchText));
} }
// filter by status // filter by status

Loading…
Cancel
Save