From ea42eff48fc523c476ef1862d52fe9addc7c6eb3 Mon Sep 17 00:00:00 2001 From: mshangle1 Date: Thu, 11 Jan 2024 09:29:07 -0500 Subject: [PATCH] Modified data processor functional param logic to split on first instance of ': 'character --- src/helpers/dataProcessor.js | 2 +- test/unit/dataProcessor.spec.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/helpers/dataProcessor.js b/src/helpers/dataProcessor.js index 67db491..5df6d27 100644 --- a/src/helpers/dataProcessor.js +++ b/src/helpers/dataProcessor.js @@ -101,7 +101,7 @@ const dataProcessor = { values.push(typeof value === 'undefined' ? raw : value); } if (refType === 'F') { - const [handlerName, ..._args] = refValue.split(':'); + const [handlerName, ..._args] = refValue.split(/:(.*)/); const handlerFun = handler.getDataFuncHandler(handlerName); const handler_data = handlerFun({ args: _args.length > 0 ? _args[0].split(',') : _args }); values.push(this.processDataRefs(handler_data)); diff --git a/test/unit/dataProcessor.spec.js b/test/unit/dataProcessor.spec.js index 7e6a12e..8b6c1d3 100644 --- a/test/unit/dataProcessor.spec.js +++ b/test/unit/dataProcessor.spec.js @@ -963,6 +963,24 @@ describe('Data Processing - Functions', () => { expect(data).deep.equals({ name: 'Jon' }); }); + it('should return data passed in as parameter', () => { + handler.addDataFuncHandler('GetParam', (ctx) => { + return ctx.args[0] + }); + + const data = dp.processData('$F{GetParam:Jon}'); + expect(data).equals('Jon'); + }); + + it('should return data passed in as parameter with semicolon', () => { + handler.addDataFuncHandler('GetParam', (ctx) => { + return ctx.args[0] + }); + + const data = dp.processData('$F{GetParam:Jon:Doe}'); + expect(data).equals('Jon:Doe'); + }); + afterEach(() => { config.data.ref.map.enabled = false; config.data.ref.map.processed = false;