Skip to content

Commit

Permalink
bug(parsing): Check quoteChar before leaving 'QUOTE'
Browse files Browse the repository at this point in the history
  • Loading branch information
ajtejankar committed Jan 29, 2016
1 parent 9af340d commit a1c2857
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ rules.set(/['"`]/, (char, state) => {
state.name = 'QUOTE';
state.quoteChar = char;
return true;
} else if (state.name === 'QUOTE') {
} else if (state.name === 'QUOTE' && char === state.quoteChar) {
state.name = 'START';
state.quoteChar = undefined;
return true;
Expand All @@ -31,7 +31,7 @@ rules.set(/\//, (char, state) => {
} else if (state.name === 'COMMENT_ML_END1') {
state.name = 'START';
return true;
} else if (state.name === 'QUOTE') {
} else if (state.name === 'QUOTE' && char === state.quoteChar) {
state.name = 'START';
state.quoteChar = undefined;
return true;
Expand Down
6 changes: 3 additions & 3 deletions test/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('parser', () => {
it('should handle regex literals in actions', () => {
let input = `
**/dep/*.!{html.js} {
let regex = /random\\/art\\{bram\\}/g;
let regex = /'random\\/"art"\\{bram\\}'/g;
pf($key);
pf($val);
}
Expand All @@ -140,8 +140,8 @@ describe('parser', () => {
it('should handle quote literals literals in actions', () => {
let input = `
**/dep/*.!{html.js} {
let quote1 = 'random { } art';
let quote2 = "random { } art"
let quote1 = 'random { } "\` art/';
let quote2 = "random { } '\` art"
let quote3 = \`random { } art\`;
pf($key);
pf($val);
Expand Down

0 comments on commit a1c2857

Please sign in to comment.