mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Support for class static blocks
This commit is contained in:
@@ -984,6 +984,42 @@ describe('JavaScriptObfuscator', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Class static block support', () => {
|
||||
const regExp: RegExp = new RegExp(
|
||||
'let _0x(\\w){4,6} *= *0x1; *' +
|
||||
'class _0x(\\w){4,6} *{ *' +
|
||||
'static *\\[\'_0x(\\w){4,6}\']; *' +
|
||||
'static *{ *' +
|
||||
'let _0x(\\w){4,6} *= *0x2; *' +
|
||||
'_0x(\\w){4,6}\\[\'_0x(\\w){4,6}\'] *= *0x3; *' +
|
||||
'_0x(\\w){4,6} *= *0x4; *' +
|
||||
'_0x(\\w){4,6} *= *0x5; *' +
|
||||
'} *' +
|
||||
'}'
|
||||
);
|
||||
|
||||
let obfuscatedCode: string;
|
||||
|
||||
beforeEach(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/class-static-block-support-1.js');
|
||||
|
||||
obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
renameGlobals: true,
|
||||
renameProperties: true
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
|
||||
console.log(obfuscatedCode);
|
||||
});
|
||||
|
||||
it('should support class static block await', () => {
|
||||
assert.match(obfuscatedCode, regExp);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Private identifiers support', () => {
|
||||
const regExp: RegExp = new RegExp(
|
||||
'class Foo *{ *' +
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
let foo = 1;
|
||||
class Foo {
|
||||
static abc;
|
||||
|
||||
static {
|
||||
let bar = 2;
|
||||
Foo.abc = 3;
|
||||
foo = 4;
|
||||
bar = 5;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user