Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class EvaluateExpression extends sfn.TaskStateBase {
* @internal
*/
protected _renderTask(): any {
const matches = this.props.expression.match(/\$[.\[][.a-zA-Z[\]0-9]+/g);
const matches = this.props.expression.match(/\$[.\[][.a-zA-Z[\]0-9-_]+/g);

let expressionAttributeValues = {};
if (matches) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,19 @@ test('with duplicated entries', async () => {
const evaluated = await handler(event);
expect(evaluated).toBe(2);
});

test('with dash and underscore in path', async () => {
// GIVEN
const event: Event = {
expression: '$.a_b + $.c-d + $[_e]',
expressionAttributeValues: {
'$.a_b': 1,
'$.c-d': 2,
'$[_e]': 3,
},
};

// THEN
const evaluated = await handler(event);
expect(evaluated).toBe(6);
});
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,28 @@ test('expression does not contain paths', () => {
},
});
});

test('with dash and underscore in path', () => {
// WHEN
const task = new tasks.EvaluateExpression(stack, 'Task', {
expression: '$.a_b + $.c-d + $[_e]',
});
new sfn.StateMachine(stack, 'SM', {
definition: task,
});

expect(stack).toHaveResource('AWS::StepFunctions::StateMachine', {
DefinitionString: {
'Fn::Join': [
'',
[
'{"StartAt":"Task","States":{"Task":{"End":true,"Type":"Task","Resource":"',
{
'Fn::GetAtt': ['Evala0d2ce44871b4e7487a1f5e63d7c3bdc4DAC06E1', 'Arn'],
},
'","Parameters":{"expression":"$.a_b + $.c-d + $[_e]","expressionAttributeValues":{"$.a_b.$":"$.a_b","$.c-d.$":"$.c-d","$[_e].$":"$[_e]"}}}}}',
],
],
},
});
});