Added optional-chaining support

This commit is contained in:
sanex3339
2020-08-06 10:28:49 +03:00
parent 88d0cbfc99
commit 971c02aed2
9 changed files with 49 additions and 12 deletions
@@ -682,6 +682,32 @@ describe('JavaScriptObfuscator', () => {
});
});
describe('Optional chaining support', () => {
const regExp: RegExp = new RegExp(
'const _0x(\\w){4,6} *= *{ *' +
'\'bar\': *\\(\\) *=> *{} *' +
'}; *' +
'_0x(\\w){4,6}\\?\\.\\[\'bar\']\\?\\.\\(\\);'
);
let obfuscatedCode: string;
beforeEach(() => {
const code: string = readFileAsString(__dirname + '/fixtures/optional-chaining-support.js');
obfuscatedCode = JavaScriptObfuscator.obfuscate(
code,
{
...NO_ADDITIONAL_NODES_PRESET
}
).getObfuscatedCode();
});
it('should support optional chaining', () => {
assert.match(obfuscatedCode, regExp);
});
});
describe('mangled identifier names generator', () => {
const regExp: RegExp = /var c *= *0x1/;