{"ScriptPreparationCode":"replaceParams = [\r\n {\r\n \u0022id_campania\u0022: \u002226757\u0022,\r\n \u0022tipo_campania\u0022: \u0022MIXTA\u0022,\r\n \u0022tipo_documento\u0022: \u0022E\u0022,\r\n \u0022cedula\u0022: \u0022915\u0022,\r\n \u0022contrato\u0022: \u00228058\u0022,\r\n \u0022Telefono\u0022: \u0022573162515999\u0022,\r\n \u0022email\u0022: \u0022jramirez@masivian.com\u0022,\r\n \u0022Nombre\u0022: \u0022Jaiber Ramirez\u0022,\r\n \u0022Valor\u0022: \u0022$ 5.122.987\u0022,\r\n \u0022Dias\u0022: \u0022733\u0022,\r\n \u0022Originador\u0022: \u0022BANCOLOMBIA\u0022,\r\n \u0022Cartera\u0022: \u0022REINTEGRA\u0022,\r\n \u0022Remitente\u0022: \u0022omarin@masivian.com\u0022,\r\n \u0022Parametros\u0022: \u0022https://www.micovinoc.com?utm_source=digital\u0026utm_medium=token\u0026utm_campaign=MiCovinoc_20191029\u0022,\r\n \u0022Url\u0022: \u0022https://www.micovinoc.com\u0022,\r\n \u0022Plantilla\u0022: \u0022\u003Ch1\u003E HOLA {{Nombre}} \u003C/h1\u003E\u0022,\r\n \u0022Asunto\u0022: \u0022este es un {{contrato}} email de prueba {{Nombre}}} este es tu telefono {{Telefono}}\u0022\r\n }\r\n ]\r\nstring = \u0022este es un {{contrato}} email de prueba {{Nombre}}} este es tu telefono {{Telefono}}\u0022","TestCases":[{"Name":"test1","Code":" if (!string || !replaceParams) { throw Error(\u0027invalid data\u0027); }\r\n let replaced = string;\r\n\r\n while (replaced.includes(\u0027{{SHORTURL}}\u0027)) replaced = replaced.replace(\u0027{{SHORTURL}}\u0027, \u0027 SHORTURL .\u0027);\r\n while (replaced.includes(\u0027{{\u0027) \u0026\u0026 replaced.includes(\u0027}}\u0027)) {\r\n let key = \u0027\u0027;\r\n if (replaced.lastIndexOf(\u0027{{\u0027) \u003C replaced.lastIndexOf(\u0027}}\u0027)) {\r\n key = replaced.substring(replaced.lastIndexOf(\u0027{{\u0027) \u002B 2, replaced.lastIndexOf(\u0027}}\u0027));\r\n } else {\r\n key = replaced.substring(replaced.indexOf(\u0027{{\u0027) \u002B 2, replaced.lastIndexOf(\u0027}}\u0027));\r\n }\r\n if (key.includes(\u0027}\u0027)) key = key.substring(0, key.indexOf(\u0027}\u0027));\r\n const value = replaceParams[key];\r\n const replaceString = new RegExp(\u0060{{${key}}}\u0060, \u0027g\u0027);\r\n // eslint-disable-next-line max-len\r\n replaced = replaced.replace(replaceString, value);\r\n while (replaced.includes(\u0060{{${value}}}\u0060)) {\r\n replaced = replaced.replace(\u0060{{${value}}}\u0060, value);\r\n }\r\n }","IsDeferred":false},{"Name":"Test2","Code":" if (!string || !replaceParams) { throw Error(\u0027invalid data\u0027); }\r\n let replaced = string;\r\n\r\n while (replaced.includes(\u0027{{SHORTURL}}\u0027)) replaced = replaced.replace(\u0027{{SHORTURL}}\u0027, \u0027 SHORTURL .\u0027);\r\n while (replaced.includes(\u0027{{\u0027) \u0026\u0026 replaced.includes(\u0027}}\u0027)) {\r\n let key = \u0027\u0027;\r\n if (replaced.lastIndexOf(\u0027{{\u0027) \u003C replaced.lastIndexOf(\u0027}}\u0027)) {\r\n key = replaced.substring(replaced.lastIndexOf(\u0027{{\u0027) \u002B 2, replaced.lastIndexOf(\u0027}}\u0027));\r\n } else {\r\n key = replaced.substring(replaced.indexOf(\u0027{{\u0027) \u002B 2, replaced.lastIndexOf(\u0027}}\u0027));\r\n }\r\n if (key.includes(\u0027}\u0027)) key = key.substring(0, key.indexOf(\u0027}\u0027));\r\n const value = replaceParams[key];\r\n const replaceString = new RegExp(\u0060{{${key}}}\u0060, \u0027g\u0027);\r\n if (!value) replaced = replaced.replace(replaceString, key);\r\n else replaced = replaced.replace(replaceString, value);\r\n }","IsDeferred":false},{"Name":"double while","Code":" if (!string || !replaceParams) { throw Error(\u0027invalid data\u0027); }\r\n let replaced = string;\r\n\r\n Object.keys(replaceParams).forEach((key) =\u003E {\r\n const value = replaceParams[key];\r\n const replaceString = new RegExp(\u0060{{${key}}}\u0060, \u0027g\u0027);\r\n replaced = replaced.replace(replaceString, value);\r\n });\r\n\r\n replaced = replaced.replace(\u0027{{SHORTURL}}\u0027, \u0027 SHORTURL .\u0027);\r\n","IsDeferred":false}]}