mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
This commit is contained in:
+22
@@ -52,4 +52,26 @@ describe('ObjectExpressionTransformer', () => {
|
||||
assert.match(obfuscatedCode, regExp);
|
||||
});
|
||||
});
|
||||
|
||||
describe('computed property name', () => {
|
||||
const regExp: RegExp = /var *_0x[a-f0-9]{4,6} *= *\{\[_0x[a-f0-9]{4,6}\]: *0x1\};/;
|
||||
|
||||
let obfuscatedCode: string;
|
||||
|
||||
before(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/computed-property-name.js');
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
);
|
||||
|
||||
obfuscatedCode = obfuscationResult.getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should ignore computed property identifier', () => {
|
||||
assert.match(obfuscatedCode, regExp);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
(function () {
|
||||
var key = 'foo';
|
||||
var test = {
|
||||
[key]: 1
|
||||
};
|
||||
})();
|
||||
+22
@@ -391,4 +391,26 @@ describe('VariableDeclarationTransformer', () => {
|
||||
assert.equal(objectPatternIdentifierName2, identifierName2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('variant #11: computed object expression identifier', () => {
|
||||
const computedObjectExpressionRegExp: RegExp = /var *_0x[a-f0-9]{4,6} *= *\{\[_0x[a-f0-9]{4,6}\]: *0x1\};/;
|
||||
|
||||
let obfuscatedCode: string;
|
||||
|
||||
before(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/computed-object-expression-identifier.js');
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
);
|
||||
|
||||
obfuscatedCode = obfuscationResult.getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should transform computed object expression identifier', () => {
|
||||
assert.match(obfuscatedCode, computedObjectExpressionRegExp);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
function foo () {
|
||||
var test = 'abc';
|
||||
|
||||
var object = {
|
||||
[test]: 1
|
||||
};
|
||||
|
||||
console.log(test);
|
||||
console.log(object.abc);
|
||||
}
|
||||
Reference in New Issue
Block a user