File tree 2 files changed +16
-23
lines changed
2 files changed +16
-23
lines changed Original file line number Diff line number Diff line change @@ -81,32 +81,23 @@ compiler.ParseScript = function (script) {
81
81
const aqLiterals = [ ]
82
82
let _script = script
83
83
let res = ''
84
- let qsMatch = _script . match ( / ^ ( [ ^ " ] * ) ( " ( [ ^ " \\ ] | \\ .) * " ) ? / )
84
+ const re = / ^ ( [ ^ " ` ] * ) ( " ( ( [ ^ " \\ ] | \\ .) * ) " | ` ( ( [ ^ ` \\ ] | \\ .) * ) ` ) ? /
85
+ let qsMatch = _script . match ( re )
85
86
while ( qsMatch && qsMatch [ 0 ] ) {
86
- let repl = qsMatch [ 2 ] || ''
87
+ let repl = qsMatch [ 2 ] || qsMatch [ 4 ] || ''
87
88
if ( repl . length > 512 ) {
88
- qLiterals . push ( repl )
89
- repl = `"QL_${ qLiterals . length - 1 } "`
89
+ if ( repl . startsWith ( '"' ) ) {
90
+ qLiterals . push ( repl )
91
+ repl = `"QL_${ qLiterals . length - 1 } "`
92
+ } else {
93
+ aqLiterals . push ( repl )
94
+ repl = `\`AL_${ aqLiterals . length - 1 } \``
95
+ }
90
96
}
91
97
res = res + qsMatch [ 1 ] + repl
92
98
_script = _script . slice ( qsMatch [ 0 ] . length )
93
- qsMatch = _script . match ( / ^ ( [ ^ " ] * ) ( " ( [ ^ " \\ ] | \\ . ) * " ) ? / )
99
+ qsMatch = _script . match ( re )
94
100
}
95
-
96
- _script = res
97
- res = ''
98
- qsMatch = _script . match ( / ^ ( [ ^ ` ] * ) ( ` ( [ ^ ` \\ ] | \\ .) * ` ) ? / )
99
- while ( qsMatch && qsMatch [ 0 ] ) {
100
- let repl = qsMatch [ 2 ] || ''
101
- if ( repl . length > 512 ) {
102
- aqLiterals . push ( repl )
103
- repl = `\`AL_${ qLiterals . length - 1 } \``
104
- }
105
- res = res + qsMatch [ 1 ] + repl
106
- _script = _script . slice ( qsMatch [ 0 ] . length )
107
- qsMatch = _script . match ( / ^ ( [ ^ ` ] * ) ( ` ( [ ^ ` \\ ] | \\ .) * ` ) ? / )
108
- }
109
-
110
101
const parsedScript = this . _ParseScript ( res )
111
102
if ( ! parsedScript ) {
112
103
return parsedScript
Original file line number Diff line number Diff line change @@ -85,9 +85,11 @@ module.exports.querySelectorPostProcess = (query) => {
85
85
* @returns {string }
86
86
*/
87
87
module . exports . unquoteToken = ( token ) => {
88
- let value = token . Child ( 'quoted_str' ) . value
89
- value = `"${ value . substr ( 1 , value . length - 2 ) } "`
90
- return JSON . parse ( value )
88
+ const value = token . Child ( 'quoted_str' ) . value
89
+ if ( value . startsWith ( '"' ) ) {
90
+ return JSON . parse ( value )
91
+ }
92
+ return value . substr ( 1 , value . length - 2 )
91
93
}
92
94
93
95
/**
You can’t perform that action at this time.
0 commit comments