mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Added more test for numbersToExpressions option
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@ import { NO_ADDITIONAL_NODES_PRESET } from '../../src/options/presets/NoCustomNo
|
||||
|
||||
let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
|
||||
`
|
||||
const foo = 0;
|
||||
const foo = 0..toString();
|
||||
const bar = 'abc';
|
||||
|
||||
console.log(foo, bar);
|
||||
|
||||
+22
@@ -164,4 +164,26 @@ describe('NumbersToNumericalExpressionsTransformer', function () {
|
||||
assert.match(obfuscatedCode, regExp);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #4: parent node is member expression', () => {
|
||||
const regExp: RegExp = /\((?:-?0x[a-zA-Z0-9]+(?: *[+\-*] *)?)*?\)\['toString']\(\);/;
|
||||
|
||||
let obfuscatedCode: string;
|
||||
|
||||
before(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/member-expression.js');
|
||||
|
||||
obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
numbersToExpressions: true
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should replace member expression with literal object with expression', () => {
|
||||
assert.match(obfuscatedCode, regExp);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user