From ee9ffc442d8e025756930b56fb1d6be6bb9246e9 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Mon, 1 May 2023 19:03:20 +0100 Subject: [PATCH] fix if else in workflow --- .../Workflow/Components/Conditions/IfElse.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/CommonServer/Types/Workflow/Components/Conditions/IfElse.ts b/CommonServer/Types/Workflow/Components/Conditions/IfElse.ts index b3dba92dbf..141ce59b38 100644 --- a/CommonServer/Types/Workflow/Components/Conditions/IfElse.ts +++ b/CommonServer/Types/Workflow/Components/Conditions/IfElse.ts @@ -91,12 +91,24 @@ export default class IfElse extends ComponentCode { }, }); + const serialize: Function = (arg: any): any => { + if (typeof arg === 'string') { + return arg.replace(/\n/g, ''); + } + + return arg; + }; + const script: VMScript = new VMScript( `module.exports = function() { - const input1 = ${(args['input-1'] as string) || ''}; + const input1 = ${ + serialize(args['input-1'] as string) || '' + }; - const input2 = ${(args['input-2'] as string) || ''}; + const input2 = ${ + serialize(args['input-2'] as string) || '' + }; return input1 ${ (args['operator'] as string) || '=='