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

Code before:
                    // trying to parse the supplied data as json to trim whitespace
                    for (const [ key, value ] of Object.entries(JSON.parse(this.monitor.headers))) {
                        command.push("--header", `'${key}: ${value}'`, "\\\n");
                    }
                } catch (e) {
                    command.push("--header", `'${this.monitor.headers}'`, "\\\n");
                }
            }
            if (this.monitor.authMethod === "basic") {
                command.push("--user", `${this.monitor.basic_auth_user}:${this.monitor.basic_auth_pass}`, "--basic", "\\\n");
            } else if (this.monitor.authmethod === "mtls") {
                command.push("--cacert", `'${this.monitor.tlsCa}'`, "\\\n", "--key", `'${this.monitor.tlsKey}'`, "\\\n", "--cert", `'${this.monitor.tlsCert}'`, "\\\n");
            } else if (this.monitor.authMethod === "ntlm") {
                command.push("--user", `'${this.monitor.authDomain ? `${this.monitor.authDomain}/` : ""}${this.monitor.basic_auth_user}:${this.monitor.basic_auth_pass}'`, "--ntlm", "\\\n");
            }
            if (this.monitor.body && this.monitor.httpBodyEncoding === "json") {
                let json = "";
                try {
                    // trying to parse the supplied data as json to trim whitespace
                    json = JSON.stringify(JSON.parse(this.monitor.body));
                } catch (e) {
                    json = this.monitor.body;
                }
                command.push("--header", "'Content-Type: application/json'", "\\\n", "--data", `'${json}'`, "\\\n");
            } else if (this.monitor.body && this.monitor.httpBodyEncoding === "xml") {
                command.push("--headers", "'Content-Type: application/xml'", "\\\n", "--data", `'${this.monitor.body}''`, "\\\n");
            }
            if (this.monitor.maxredirects) {
                command.push("--location", "--max-redirs", this.monitor.maxredirects, "\\\n");
            }
            if (this.monitor.timeout) {
                command.push("--max-time", this.monitor.timeout, "\\\n");
            }
            if (this.monitor.maxretries) {
                command.push("--retry", this.monitor.maxretries, "\\\n");
            }
            command.push("--url", this.monitor.url);
            return command.join(" ");
        },

        ipRegex() {

            // Allow to test with simple dns server with port (127.0.0.1:5300)
            if (! isDev) {
                return this.ipRegexPattern;
            }
            return null;
        },

        pageName() {
            let name = "Add New Monitor";

Review comment (suggestion):
```suggestion
                command.push("--headers", "'Content-Type: application/xml'", "\\\n", "--data", `'${this.monitor.body}'`, "\\\n");
```

Code after:
            processing: false,
            monitor: {
                notificationIDList: {},
                // Do not add default value here, please check init() method
            },
            acceptedStatusCodeOptions: [],
            dnsresolvetypeOptions: [],
            kafkaSaslMechanismOptions: [],
            ipOrHostnameRegexPattern: hostNameRegexPattern(),
            mqttIpOrHostnameRegexPattern: hostNameRegexPattern(true),
            gameList: null,
            connectionStringTemplates: {
                "sqlserver": "Server=<hostname>,<port>;Database=<your database>;User Id=<your user id>;Password=<your password>;Encrypt=<true/false>;TrustServerCertificate=<Yes/No>;Connection Timeout=<int>",
                "postgres": "postgres://username:password@host:port/database",
                "mysql": "mysql://username:password@host:port/database",
                "redis": "redis://user:password@host:port",
                "mongodb": "mongodb://username:password@host:port/database",
            },
            draftGroupName: null,
            remoteBrowsersEnabled: false,
        };
    },

    computed: {

        curlCommand() {
            const command = [ "curl", "--verbose", "--head", "--request", this.monitor.method, "\\\n", "--user-agent", userAgent, "\\\n" ];
            if (this.monitor.ignoreTls) {
                command.push("--insecure", "\\\n");
            }
            if (this.monitor.headers) {
                try {
                    // trying to parse the supplied data as json to trim whitespace
                    for (const [ key, value ] of Object.entries(JSON.parse(this.monitor.headers))) {
                        command.push("--header", `'${key}: ${value}'`, "\\\n");
                    }
                } catch (e) {
                    command.push("--header", `'${this.monitor.headers}'`, "\\\n");
                }
            }
            if (this.monitor.authMethod === "basic") {
                command.push("--user", `${this.monitor.basic_auth_user}:${this.monitor.basic_auth_pass}`, "--basic", "\\\n");
            } else if (this.monitor.authmethod === "mtls") {
                command.push("--cacert", `'${this.monitor.tlsCa}'`, "\\\n", "--key", `'${this.monitor.tlsKey}'`, "\\\n", "--cert", `'${this.monitor.tlsCert}'`, "\\\n");
            } else if (this.monitor.authMethod === "ntlm") {
                command.push("--user", `'${this.monitor.authDomain ? `${this.monitor.authDomain}/` : ""}${this.monitor.basic_auth_user}:${this.monitor.basic_auth_pass}'`, "--ntlm", "\\\n");
            }
            if (this.monitor.body && this.monitor.httpBodyEncoding === "json") {
                let json = "";
                try {
                    // trying to parse the supplied data as json to trim whitespace