diff --git a/packages/service/core/workflow/dispatch/tools/http468.ts b/packages/service/core/workflow/dispatch/tools/http468.ts index da7b82192..a7ce392d5 100644 --- a/packages/service/core/workflow/dispatch/tools/http468.ts +++ b/packages/service/core/workflow/dispatch/tools/http468.ts @@ -100,10 +100,9 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise = { [NodeInputKeyEnum.addInputParam]: concatVariables, ...concatVariables }; @@ -135,19 +134,11 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise match.slice(2, -2)))]; - for (const key of uniqueKeys1) { - text = text.replace(new RegExp(`{{(${key})}}`, 'g'), () => valToStr(variables[key])); - } - - // 2. Replace {{key.key}} variables - const regex2 = /\{\{\$([^.]+)\.([^$]+)\$\}\}/g; - const matches2 = [...text.matchAll(regex2)]; - if (matches2.length === 0) return text; - matches2.forEach((match) => { + // 1. Replace {{key.key}} variables + const regex1 = /\{\{\$([^.]+)\.([^$]+)\$\}\}/g; + const matches1 = [...text.matchAll(regex1)]; + if (matches1.length === 0) return text; + matches1.forEach((match) => { const nodeId = match[1]; const id = match[2]; @@ -173,6 +164,14 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise formatVal); }); + // 2. Replace {{key}} variables + const regex2 = /{{([^}]+)}}/g; + const matches2 = text.match(regex2) || []; + const uniqueKeys2 = [...new Set(matches2.map((match) => match.slice(2, -2)))]; + for (const key of uniqueKeys2) { + text = text.replace(new RegExp(`{{(${key})}}`, 'g'), () => valToStr(allVariables[key])); + } + return text.replace(/(".*?")\s*:\s*undefined\b/g, '$1: null'); };