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

Code before:
                    hostname = hostname.replace(/^(mqtt|ws)s?:\/\//, "");
                }

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

                // Wildcard is allowed only for DNS
                if (!isFQDN(hostname, {
                    allow_wildcard: this.monitor.type === "dns",
                    require_tld: false,
                    allow_underscores: true,
                    allow_trailing_dot: true,
                }) && !isIP(hostname)) {
                    if (this.monitor.type === "dns") {
                        toast.error(this.$t("invalidDNSHostname"));
                    } else {
                        toast.error(this.$t("invalidHostnameOrIP"));
                    }
                    return false;
                }
            }

            // Validate URL field input for various monitors
            if ((this.monitor.type === "http" || this.monitor.type === "keyword" || this.monitor.type === "json-query" || this.monitor.type === "websocket-upgrade" || this.monitor.type === "real-browser") && this.monitor.url) {
                try {
                    const url = new URL(this.monitor.url);
                    // Browser can encode *.hostname.com to %2A.hostname.com
                    if (url.hostname.includes("*") || url.hostname.includes("%2A")) {
                        toast.error(this.$t("wildcardOnlyForDNS"));
                        return false;
                    }
                    if (!isFQDN(url.hostname, {
                        require_tld: false,
                        allow_underscores: true,
                        allow_trailing_dot: true,
                    }) && !isIP(url.hostname)) {
                        toast.error(this.$t("invalidHostnameOrIP"));
                        return false;
                    }
                } catch (err) {
                    toast.error(this.$t("invalidURL"));
                    return false;
                }
            }

            return true;
        },

        resetToken() {

Review comment (suggestion):
the change above is good 👍🏻 

```suggestion
            if (["http", "keyword", "json-query", "websocket-upgrade", "real-browser"].includes(this.monitor.type) && this.monitor.url) {
```

Code after:
                    hostname = hostname.replace(/^(mqtt|ws)s?:\/\//, "");
                }

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

                // Wildcard is allowed only for DNS
                if (!isFQDN(hostname, {
                    allow_wildcard: this.monitor.type === "dns",
                    require_tld: false,
                    allow_underscores: true,
                    allow_trailing_dot: true,
                }) && !isIP(hostname)) {
                    if (this.monitor.type === "dns") {
                        toast.error(this.$t("invalidDNSHostname"));
                    } else {
                        toast.error(this.$t("invalidHostnameOrIP"));
                    }
                    return false;
                }
            }

            // Validate URL field input for various monitors
            if ([ "http", "keyword", "json-query", "websocket-upgrade", "real-browser" ].includes(this.monitor.type) && this.monitor.url) {
                try {
                    const url = new URL(this.monitor.url);
                    // Browser can encode *.hostname.com to %2A.hostname.com
                    if (url.hostname.includes("*") || url.hostname.includes("%2A")) {
                        toast.error(this.$t("wildcardOnlyForDNS"));
                        return false;
                    }
                    if (!isFQDN(url.hostname, {
                        require_tld: false,
                        allow_underscores: true,
                        allow_trailing_dot: true,
                    }) && !isIP(url.hostname)) {
                        toast.error(this.$t("invalidHostnameOrIP"));
                        return false;
                    }
                } catch (err) {
                    toast.error(this.$t("invalidURL"));
                    return false;
                }
            }

            return true;
        },

        resetToken() {