mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Sync with master
This commit is contained in:
@@ -968,6 +968,35 @@ describe('JavaScriptObfuscator', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Private identifiers support', () => {
|
||||
const regExp: RegExp = new RegExp(
|
||||
'class Foo *{ *' +
|
||||
'#bar *= *0x1; *' +
|
||||
'\\[\'method\'] *\\(\\) *{ *' +
|
||||
'this\.#bar *= *0x2;' +
|
||||
'} *' +
|
||||
'}'
|
||||
);
|
||||
|
||||
let obfuscatedCode: string;
|
||||
|
||||
beforeEach(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/private-identifier.js');
|
||||
|
||||
obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
renameProperties: true
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should support private identifiers', () => {
|
||||
assert.match(obfuscatedCode, regExp);
|
||||
});
|
||||
});
|
||||
|
||||
describe('mangled identifier names generator', () => {
|
||||
const regExp: RegExp = /var c *= *0x1/;
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class Foo {
|
||||
#bar = 1;
|
||||
|
||||
method() {
|
||||
this.#bar = 2;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user