Tighten parameter substitution tolerance
In collection templating syntax, do not tolerate whitespace after dollar sign. So while `{{ $param }}` is valid `{{ $ param }}` will be ignored.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { RegexParser, IPrimitiveExpression } from '../Parser/RegexParser';
|
import { RegexParser, IPrimitiveExpression } from '../Parser/RegexParser';
|
||||||
|
|
||||||
export class ParameterSubstitutionParser extends RegexParser {
|
export class ParameterSubstitutionParser extends RegexParser {
|
||||||
protected readonly regex = /{{\s*\$\s*([^}| ]+)\s*}}/g;
|
protected readonly regex = /{{\s*\$([^}| ]+)\s*}}/g;
|
||||||
protected buildExpression(match: RegExpMatchArray): IPrimitiveExpression {
|
protected buildExpression(match: RegExpMatchArray): IPrimitiveExpression {
|
||||||
const parameterName = match[1];
|
const parameterName = match[1];
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ describe('ParameterSubstitutionParser', () => {
|
|||||||
code: 'He{{$firstParameter}}!!',
|
code: 'He{{$firstParameter}}!!',
|
||||||
expected: [new ExpressionPosition(2, 21) ],
|
expected: [new ExpressionPosition(2, 21) ],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'does not tolerate space after dollar sign',
|
||||||
|
code: 'He{{ $ firstParameter }}!!',
|
||||||
|
expected: [ ],
|
||||||
|
},
|
||||||
];
|
];
|
||||||
for (const testCase of testCases) {
|
for (const testCase of testCases) {
|
||||||
it(testCase.name, () => {
|
it(testCase.name, () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user