mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-02-25 21:15:55 +00:00
Compare commits
8 commits
6087a16c39
...
b64e546bc9
Author | SHA1 | Date | |
---|---|---|---|
|
b64e546bc9 | ||
|
012256b297 | ||
|
c0d7171dbf | ||
|
d0d03c05d6 | ||
|
1e0342949f | ||
|
c486e5bff9 | ||
|
08a45637c8 | ||
|
39da894598 |
1 changed files with 19 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue