This commit is contained in:
Ionys 2025-01-26 13:21:50 +00:00 committed by GitHub
commit 6087a16c39
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 // 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(); try {
searchTextMatch = // Escape special characters for use in the regular expression
monitor.name.toLowerCase().includes(loweredSearchText) const escapeRegExp = (string) => string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|| monitor.tags.find(tag => tag.name.toLowerCase().includes(loweredSearchText)
|| tag.value?.toLowerCase().includes(loweredSearchText)); 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 // filter by status