This commit is contained in:
GJS 2025-01-26 13:28:15 +00:00 committed by GitHub
commit 51095ffdd4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 33 additions and 8 deletions

View file

@ -320,15 +320,35 @@ export default {
} }
} }
// filter by search text // Filter monitors based on the search text
// finds monitor name, tag name or tag value // Matches monitor name, URL, hostname, DNS resolve server, or tag names and values
let searchTextMatch = true; let searchTextMatch = true;
if (this.searchText !== "") { if (this.searchText !== "") {
const loweredSearchText = this.searchText.toLowerCase(); try {
// Escape special characters for use in the regular expression
const escapeRegExp = (string) => {
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
};
// Create a case-insensitive regex for the search text
const escapedSearchText = escapeRegExp(this.searchText);
const regex = new RegExp(escapedSearchText, "i");
// Test the regex against strings safely
const safeRegexTest = (str) => str && regex.test(str);
// Check if any relevant fields match the search text
searchTextMatch = searchTextMatch =
monitor.name.toLowerCase().includes(loweredSearchText) regex.test(monitor.name) ||
|| monitor.tags.find(tag => tag.name.toLowerCase().includes(loweredSearchText) safeRegexTest(monitor.url) ||
|| tag.value?.toLowerCase().includes(loweredSearchText)); safeRegexTest(monitor.hostname) ||
safeRegexTest(monitor.dns_resolve_server) ||
monitor.tags.some(tag => regex.test(tag.name) || safeRegexTest(tag.value));
} catch (e) {
// Log error if the regex pattern is invalid
console.error("Invalid regex pattern:", e);
searchTextMatch = false;
}
} }
// filter by status // filter by status

View file

@ -1719,7 +1719,12 @@ message HealthCheckResponse {
this.monitor.headers = JSON.stringify(JSON.parse(this.monitor.headers), null, 4); this.monitor.headers = JSON.stringify(JSON.parse(this.monitor.headers), null, 4);
} }
if (this.monitor.hostname) { // Check if the 'monitor' object exists and contains a 'hostname' property.
if (this.monitor?.hostname) {
// Initialize the 'url' property of 'monitor' to the base URL scheme.
this.monitor.url = "https://";
// Remove any leading or trailing spaces from the 'hostname' value.
this.monitor.hostname = this.monitor.hostname.trim(); this.monitor.hostname = this.monitor.hostname.trim();
} }