mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-01-12 14:27:35 -08:00
fix(monitors search): Correctly handle null/undefined/empty values. Also optimize a bit search tags by replacing .find
with .some
.
Thanks @homelab-alpha
This commit is contained in:
parent
1e0342949f
commit
d0d03c05d6
|
@ -324,14 +324,21 @@ 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 regex = new RegExp(this.searchText, "i");
|
try {
|
||||||
|
const regex = new RegExp(this.searchText, "i"); // "i" for case-insensitive matching
|
||||||
|
|
||||||
|
const safeRegexTest = (str) => str && regex.test(str);
|
||||||
|
|
||||||
searchTextMatch =
|
searchTextMatch =
|
||||||
regex.test(monitor.name) ||
|
regex.test(monitor.name) ||
|
||||||
regex.test(monitor.url) ||
|
safeRegexTest(monitor.url) ||
|
||||||
regex.test(monitor.hostname) ||
|
safeRegexTest(monitor.hostname) ||
|
||||||
regex.test(monitor.dns_resolve_server) ||
|
safeRegexTest(monitor.dns_resolve_server) ||
|
||||||
monitor.tags.find((tag) => regex.test(tag.name) || regex.test(tag.value));
|
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
|
||||||
|
|
Loading…
Reference in a new issue