mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Added ability to add specific node guard to the black list of nodes.
This nodes wont obfuscated.
This commit is contained in:
@@ -439,6 +439,40 @@ describe('JavaScriptObfuscator', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('`\'use strict\';` operator', () => {
|
||||
const useStrictOperatorRegExp: RegExp = /'use *strict';/;
|
||||
const stringArrayLatinRegExp: RegExp = /var _0x(\w){4} *= *\['abc'\];/;
|
||||
const stringArrayCallRegExp: RegExp = /var *test *= *_0x(\w){4}\('0x0'\);$/;
|
||||
|
||||
let obfuscatedCode: string;
|
||||
|
||||
beforeEach(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/use-strict-operator.js');
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
stringArray: true,
|
||||
stringArrayThreshold: 1
|
||||
}
|
||||
);
|
||||
|
||||
obfuscatedCode = obfuscationResult.getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('match #1: shouldn\'t obfuscate `use strict` operator', () => {
|
||||
assert.match(obfuscatedCode, useStrictOperatorRegExp);
|
||||
});
|
||||
|
||||
it('match #2: should return correct obfuscated code', () => {
|
||||
assert.match(obfuscatedCode, stringArrayLatinRegExp);
|
||||
});
|
||||
|
||||
it('match #3: should return correct obfuscated code', () => {
|
||||
assert.match(obfuscatedCode, stringArrayCallRegExp);
|
||||
});
|
||||
});
|
||||
|
||||
describe('mangle', () => {
|
||||
const regExp: RegExp = /var *a *= *0x1/;
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
var test = 'abc';
|
||||
Reference in New Issue
Block a user