From 4fcbce62ebac9432f68c084a81fa74c99c6f7da5 Mon Sep 17 00:00:00 2001 From: Jeeva Ramachandran <120017870+JeevaRamu0104@users.noreply.github.com> Date: Thu, 12 Dec 2024 13:43:33 +0530 Subject: [PATCH] fix: custom http headers (#1910) --- .../PaymentSettings/PaymentSettings.res | 31 +++++++++---------- src/server/config.mjs | 4 +-- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/screens/Developer/PaymentSettings/PaymentSettings.res b/src/screens/Developer/PaymentSettings/PaymentSettings.res index 7ecd96213..598ed668f 100644 --- a/src/screens/Developer/PaymentSettings/PaymentSettings.res +++ b/src/screens/Developer/PaymentSettings/PaymentSettings.res @@ -66,12 +66,24 @@ module AuthenticationInput = { onBlur: _ => (), onChange: ev => { let value = ReactEvent.Form.target(ev)["value"] + let regexForProfileName = "^([a-z]|[A-Z]|[0-9]|_|-)+$" + let isValid = if value->String.length <= 2 { + true + } else if ( + value->isEmptyString || + value->String.length > 64 || + !RegExp.test(RegExp.fromString(regexForProfileName), value) + ) { + false + } else { + true + } if value->String.length <= 0 { let name = `outgoing_webhook_custom_http_headers.${key}` form.change(name, JSON.Encode.null) } - switch value->getOptionIntFromString->Option.isNone { - | true => setKey(_ => value) + switch (value->getOptionIntFromString->Option.isNone, isValid) { + | (true, true) => setKey(_ => value) | _ => () } }, @@ -85,7 +97,6 @@ module AuthenticationInput = { if key->String.length > 0 { let name = `outgoing_webhook_custom_http_headers.${key}` form.change(name, metaValue->JSON.Encode.string) - setAllowEdit(_ => false) } }, onChange: ev => { @@ -99,6 +110,7 @@ module AuthenticationInput = { let allowEditConfiguration = () => { setValue(_ => "") + form.change(`outgoing_webhook_custom_http_headers.${key}`, JSON.Encode.null) setAllowEdit(_ => true) setShowModal(_ => false) } @@ -129,19 +141,6 @@ module AuthenticationInput = { /> - -
-
-
diff --git a/src/server/config.mjs b/src/server/config.mjs index 8e391cf86..f539d6749 100644 --- a/src/server/config.mjs +++ b/src/server/config.mjs @@ -105,10 +105,10 @@ const configHandler = async ( try { const config = await readTomlConfig(filePath, res); let merchantConfig = config.default; - + let isDomainExitsInEnv = process.env[`${domain}`]; if (config[domain] && Object.keys(config[domain]).length > 0) { merchantConfig = updateConfigWithEnv(config[domain], domain, "theme"); - } else if (domain.length > 0) { + } else if (domain.length > 0 && isDomainExitsInEnv) { merchantConfig = updateConfigWithEnv(config.default, domain, "theme"); } else { merchantConfig = updateConfigWithEnv(merchantConfig, "default", "");