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

Code before:
                    headers = ` -H '${this.monitor.headers.replace(/\n/g, "")}'`;
                }
            }
            if (this.monitor.body && this.monitor.httpBodyEncoding === "json") {
                let json = "";
                try {
                    const jsonParsed = JSON.parse(this.monitor.body);
                    json = JSON.stringify(jsonParsed);
                    body = ` --json '${json}'`;
                } catch (e) {
                    json = this.monitor.body.replace(/\n/g, "");
                    body = ` --json '${json}'`;
                }
                method = "";
            } else if (this.monitor.body && this.monitor.method === "POST" && this.monitor.httpBodyEncoding === "xml") {
                headers += " -H 'Content-Type: application/xml'";
                body = ` -d ${this.monitor.body.replace(/\n/g, "")}`;
            } else if (this.monitor.body) {
                body = ` -d ${this.monitor.body.replace(/\n/g, "")}`;
            }
            if (this.monitor.authMethod === "basic") {
                basicAuth = ` -u ${this.monitor.basic_auth_user}:${this.monitor.basic_auth_pass}`;
            }
            return `curl -v${method}${this.monitor.timeout ? ` -m ${this.monitor.timeout}` : ""}${this.monitor.ignoreTls ? " -k" : ""}${basicAuth} '${this.monitor.url}'${headers}${body}`;
        },

        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";
            if (this.isClone) {
                name = "Clone Monitor";
            } else if (this.isEdit) {
                name = "Edit";
            }
            return this.$t(name);
        },
        remoteBrowsersOptions() {
            return this.$root.remoteBrowserList.map(browser => {
                return {
                    label: browser.name,
                    value: browser.id,
                };
            });

Review comment (suggestion):
As would be expected there are a few options which are missing. (that is normal when we don't have a shema / currently don't use typescript or docs what the internal data model is 😅)
- `--user-agent <agent>`
  https://github.com/louislam/uptime-kuma/blob/00717755254b441c6bfb7cecab15e5a741507499/server/uptime-kuma-server.js#L487
- `--insecure` if "Ignore TLS/SSL error for HTTPS websites" is set
  ![image](https://github.com/user-attachments/assets/6dfe2543-cdf6-43c0-9543-4b9b2f728af8)
- `--max-redirs <cnt>` and `--location` if the following is not `0`
  ![image](https://github.com/user-attachments/assets/cfb5a9fd-2546-48e2-be2a-d87401133bbb)

If you are motivated (not a requirement, but please document this in the modal if the command does not support this):
- modeling of our retry mechanism via `--retry-delay <seconds>` and `--retry-max-time <seconds>`
- read into `--max-time` and `--connect-timeout` and see if we can approximate our timeout via this.
- proxy support (such a pain)


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