Repository: louislam/uptime-kuma
File: src/pages/EditMonitor.vue (Vue)

Code before:
        },

        addKafkaProducerBroker(newBroker) {
            this.monitor.kafkaProducerBrokers.push(newBroker);
        },

        addRabbitmqNode(newNode) {
            this.monitor.rabbitmqNodes.push(newNode);
        },

        /**
         * Validate form input
         * @returns {boolean} Is the form input valid?
         */
        isInputValid() {
            if (this.monitor.body && (!this.monitor.httpBodyEncoding || this.monitor.httpBodyEncoding === "json")) {
                try {
                    JSON.parse(this.monitor.body);
                } catch (err) {
                    toast.error(this.$t("BodyInvalidFormat", {error: err.message}));
                    return false;
                }
            }
            if (this.monitor.headers) {
                try {
                    JSON.parHeadersInvalidFormatse(this.monitor.headers);
                } catch (err) {
                    toast.error(this.$t("HeadersInvalidFormat", {error: err.message}));
                    return false;
                }
            }
            if (this.monitor.type === "docker") {
                if (this.monitor.docker_host == null) {
                    toast.error(this.$t("DockerHostRequired"));
                    return false;
                }
            }

            if (this.monitor.type === "rabbitmq") {
                if (this.monitor.rabbitmqNodes.length === 0) {
                    toast.error(this.$t("rabbitmqNodesRequired"));
                    return false;
                }
                if (!this.monitor.rabbitmqNodes.every(node => node.startsWith("http://") || node.startsWith("https://"))) {
                    toast.error(this.$t("rabbitmqNodesInvalid"));
                    return false;
                }
            }

            // Validate MQTT WebSocket Path pattern if present
            if (this.monitor.type === "mqtt" && this.monitor.mqttWebsocketPath) {

Review comment (suggestion):
```suggestion
                    JSON.parHeadersInvalidFormatse(this.monitor.headers);
```
```suggestion
                    JSON.parse(this.monitor.headers);
```

Code after:
                    JSON.parse(this.monitor.body);
                } catch (err) {
                    toast.error(this.$t("BodyInvalidFormatBecause", {error: err.message}));
                    return false;
                }
            }
            if (this.monitor.headers) {
                try {
                    JSON.parse(this.monitor.headers);
                } catch (err) {
                    toast.error(this.$t("HeadersInvalidFormatBecause", {error: err.message}));
                    return false;
                }
            }
            if (this.monitor.type === "docker") {
                if (this.monitor.docker_host == null) {
                    toast.error(this.$t("DockerHostRequired"));
                    return false;
                }
            }

            if (this.monitor.type === "rabbitmq") {
                if (this.monitor.rabbitmqNodes.length === 0) {
                    toast.error(this.$t("rabbitmqNodesRequired"));
                    return false;
                }
                if (!this.monitor.rabbitmqNodes.every(node => node.startsWith("http://") || node.startsWith("https://"))) {
                    toast.error(this.$t("rabbitmqNodesInvalid"));
                    return false;
                }
            }

            // Validate MQTT WebSocket Path pattern if present
            if (this.monitor.type === "mqtt" && this.monitor.mqttWebsocketPath) {
                const pattern = /^\/[A-Za-z0-9-_&()*+]*$/;
                if (!pattern.test(this.monitor.mqttWebsocketPath)) {
                    toast.error(this.$t("mqttWebsocketPathInvalid"));
                    return false;
                }
            }

            // Validate hostname field input for various monitors
            if ([ "mqtt", "dns", "port", "ping", "steam", "gamedig", "radius", "tailscale-ping", "smtp", "snmp" ].includes(this.monitor.type) && this.monitor.hostname) {
                let hostname = this.monitor.hostname.trim();

                if (this.monitor.type === "mqtt") {
                    hostname = hostname.replace(/^(mqtt|ws)s?:\/\//, "");
                }

                if (this.monitor.type === "dns" && isIP(hostname)) {
                    toast.error(this.$t("hostnameCannotBeIP"));