Skip to content

Commit 031d4af

Browse files
committed
sojsonv7: fix bug when stringArrayFunction is defined in VariableDeclarator #66
Signed-off-by: echo094 <20028238+echo094@users.noreply.github.com>
1 parent 4985fac commit 031d4af

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/plugin/sojsonv7.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function decodeGlobal(ast) {
121121
if (node_table.node.id) {
122122
var_string_table = node_table.node.id.name
123123
} else {
124-
while (!t.isVariableDeclarator(node_table)) {
124+
while (!node_table.isVariableDeclarator()) {
125125
node_table = node_table.parentPath
126126
}
127127
var_string_table = node_table.node.id.name
@@ -159,7 +159,11 @@ function decodeGlobal(ast) {
159159
let decrypt_val
160160
let binds = refs.string_path.scope.getBinding(var_string_table)
161161
// remove path of string table
162-
decrypt_code[1] = refs.string_path.node
162+
if (refs.string_path.isVariableDeclarator()) {
163+
decrypt_code[1] = t.variableDeclaration('var', [refs.string_path.node])
164+
} else {
165+
decrypt_code[1] = refs.string_path.node
166+
}
163167
refs.string_path.remove()
164168
// iterate refs
165169
for (let bind of binds.referencePaths) {

0 commit comments

Comments
 (0)