Merge 012256b297df94818d500e7659858bf9aaf75ed8 into 8d8e3e5a8e78030b8ffbe258dc872b8bea234390

This commit is contained in:
Ionys 2025-04-18 23:34:26 +00:00 committed by GitHub
commit 89f39d1a6b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -324,11 +324,25 @@ export default {
// finds monitor name, tag name or tag value
let searchTextMatch = true;
if (this.searchText !== "") {
const loweredSearchText = this.searchText.toLowerCase();
searchTextMatch =
monitor.name.toLowerCase().includes(loweredSearchText)
|| monitor.tags.find(tag => tag.name.toLowerCase().includes(loweredSearchText)
|| tag.value?.toLowerCase().includes(loweredSearchText));
try {
// Escape special characters for use in the regular expression
const escapeRegExp = (string) => string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const escapedSearchText = escapeRegExp(this.searchText);
const regex = new RegExp(escapedSearchText, "i");
const safeRegexTest = (str) => str && regex.test(str);
searchTextMatch =
regex.test(monitor.name) ||
safeRegexTest(monitor.url) ||
safeRegexTest(monitor.hostname) ||
safeRegexTest(monitor.dns_resolve_server) ||
monitor.tags.some(tag => regex.test(tag.name) || safeRegexTest(tag.value));
} catch (e) {
console.error("Invalid regex pattern:", e);
searchTextMatch = false;
}
}
// filter by status