fix parseExpression bug

This commit is contained in:
Bowen Tan 2021-09-07 17:09:27 +08:00
parent ae564e926b
commit 6566734282
2 changed files with 2 additions and 1 deletions

View File

@ -8,6 +8,7 @@ describe('parseExpression function', () => {
expect(parseExpression('Hello, {{ value }}!')).toMatchObject([
{ expression: 'Hello, ', isDynamic: false },
{ expression: 'value', isDynamic: true },
{ expression: '!', isDynamic: false },
]);
expect(
parseExpression('{{ $listItem.name }} is in {{ root.listTitle }} list')

View File

@ -70,7 +70,7 @@ export function parseExpression(
}
}
if (r > l) {
if (r >= l && l < str.length) {
res.push({
expression: str.substring(l, r + 1),
isDynamic: false,