Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle back-ticks in expression #3292

Merged
merged 1 commit into from
Jul 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/parsers/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const improperKeywordsRE =

const wsRE = /\s/g
const newlineRE = /\n/g
const saveRE = /[\{,]\s*[\w\$_]+\s*:|('(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`)|new |typeof |void /g
const saveRE = /[\{,]\s*[\w\$_]+\s*:|('(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\"']|\\.)*`|`(?:[^`\\]|\\.)*`)|new |typeof |void /g
const restoreRE = /"(\d+)"/g
const pathTestRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?'\]|\[".*?"\]|\[\d+\]|\[[A-Za-z_$][\w$]*\])*$/
const identRE = /[^\w$\.](?:[A-Za-z_$][\w$]*)/g
Expand Down
12 changes: 12 additions & 0 deletions test/unit/specs/parsers/expression_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ var testCases = [
scope: {c: 32},
expected: { a: '35', b: 32 }
},
{
// Object with string values with back-quotes
exp: '[{"a":"he`llo"},{"b":"world"},{"c":55}]',
scope: {},
expected: [{ 'a': 'he`llo'}, { 'b': 'world'}, { 'c': 55}]
},
{
// Object with string values and back quotes (single quoted string)
exp: '[{\'a\':\'he`llo\'},{\'b\':\'world\'},{\'c\':55}]',
scope: {},
expected: [{ 'a': 'he`llo'}, { 'b': 'world'}, { 'c': 55}]
},
{
// dollar signs and underscore
exp: "_a + ' ' + $b",
Expand Down