From 1e0342949fdec594838a212835cb6470879db5ec Mon Sep 17 00:00:00 2001 From: Ionys <9364594+Ionys320@users.noreply.github.com> Date: Sun, 22 Dec 2024 10:40:33 +0100 Subject: [PATCH] feat(monitors search): Use regex instead of `LowerCase` Except with less than 20 monitors, regex seems faster. --- src/components/MonitorList.vue | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/MonitorList.vue b/src/components/MonitorList.vue index 43196a11d..9dab5e28a 100644 --- a/src/components/MonitorList.vue +++ b/src/components/MonitorList.vue @@ -324,14 +324,14 @@ export default { // finds monitor name, tag name or tag value let searchTextMatch = true; if (this.searchText !== "") { - const loweredSearchText = this.searchText.toLowerCase(); + const regex = new RegExp(this.searchText, "i"); + searchTextMatch = - monitor.name.toLowerCase().includes(loweredSearchText) - || monitor.url?.toLowerCase().includes(loweredSearchText) - || monitor.hostname?.toLowerCase().includes(loweredSearchText) - || monitor.dns_resolve_server?.toLowerCase().includes(loweredSearchText) - || monitor.tags.find(tag => tag.name.toLowerCase().includes(loweredSearchText) - || tag.value?.toLowerCase().includes(loweredSearchText)); + regex.test(monitor.name) || + regex.test(monitor.url) || + regex.test(monitor.hostname) || + regex.test(monitor.dns_resolve_server) || + monitor.tags.find((tag) => regex.test(tag.name) || regex.test(tag.value)); } // filter by status