Skip to content

Commit

Permalink
Modified data processor functional param logic to split on first inst…
Browse files Browse the repository at this point in the history
…ance of ': 'character
  • Loading branch information
mshangle1 committed Jan 11, 2024
1 parent 2af9418 commit ea42eff
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/helpers/dataProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
18 changes: 18 additions & 0 deletions test/unit/dataProcessor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ea42eff

Please sign in to comment.