|
|
@ -4,6 +4,7 @@ export function parseFilters (exp: string): string { |
|
|
|
let inSingle = false |
|
|
|
let inDouble = false |
|
|
|
let inTemplateString = false |
|
|
|
let inRegex = false |
|
|
|
let curly = 0 |
|
|
|
let square = 0 |
|
|
|
let paren = 0 |
|
|
@ -14,14 +15,13 @@ export function parseFilters (exp: string): string { |
|
|
|
prev = c |
|
|
|
c = exp.charCodeAt(i) |
|
|
|
if (inSingle) { |
|
|
|
// check single quote
|
|
|
|
if (c === 0x27 && prev !== 0x5C) inSingle = !inSingle |
|
|
|
if (c === 0x27 && prev !== 0x5C) inSingle = false |
|
|
|
} else if (inDouble) { |
|
|
|
// check double quote
|
|
|
|
if (c === 0x22 && prev !== 0x5C) inDouble = !inDouble |
|
|
|
if (c === 0x22 && prev !== 0x5C) inDouble = false |
|
|
|
} else if (inTemplateString) { |
|
|
|
// check template literal
|
|
|
|
if (c === 0x60 && prev !== 0x5C) inTemplateString = !inTemplateString |
|
|
|
if (c === 0x60 && prev !== 0x5C) inTemplateString = false |
|
|
|
} else if (inRegex) { |
|
|
|
if (c === 0x2f && prev !== 0x5C) inRegex = false |
|
|
|
} else if ( |
|
|
|
c === 0x7C && // pipe
|
|
|
|
exp.charCodeAt(i + 1) !== 0x7C && |
|
|
@ -40,6 +40,7 @@ export function parseFilters (exp: string): string { |
|
|
|
case 0x22: inDouble = true; break // "
|
|
|
|
case 0x27: inSingle = true; break // '
|
|
|
|
case 0x60: inTemplateString = true; break // `
|
|
|
|
case 0x2f: inRegex = true; break // /
|
|
|
|
case 0x28: paren++; break // (
|
|
|
|
case 0x29: paren--; break // )
|
|
|
|
case 0x5B: square++; break // [
|
|
|
|