From 33ebfefc5892a9cabd632cc075d9125fb2a9fa1c Mon Sep 17 00:00:00 2001 From: GJS Date: Sun, 29 Dec 2024 07:31:50 +0100 Subject: [PATCH] Updated: Enhance null safety and set default URL in `EditMonitor.vue` - Added optional chaining to safely access `this.monitor.hostname`. - Introduced default URL (`https://`) assignment to `this.monitor.url`. - Ensured `hostname` is trimmed after the URL is set. modified: src/pages/EditMonitor.vue --- src/pages/EditMonitor.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index a83f91cab..f70145ebd 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -1719,7 +1719,12 @@ message HealthCheckResponse { 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(); }