mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Switched form escodegen to @javascript-obfuscator/escodegen
Added tests for some es11/es12 features
This commit is contained in:
@@ -641,6 +641,30 @@ describe('JavaScriptObfuscator', () => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* https://github.com/javascript-obfuscator/javascript-obfuscator/issues/710
|
||||
*/
|
||||
describe('export * as', () => {
|
||||
const regExp: RegExp = /export *\* *as foo from *'bar';/;
|
||||
|
||||
let obfuscatedCode: string;
|
||||
|
||||
beforeEach(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/export-all-named-support.js');
|
||||
|
||||
obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should support `export * as` syntax', () => {
|
||||
assert.match(obfuscatedCode, regExp);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* https://github.com/estools/escodegen/pull/407
|
||||
*/
|
||||
@@ -712,6 +736,48 @@ describe('JavaScriptObfuscator', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Nullish coalescing support', () => {
|
||||
const regExp: RegExp = /\(foo *\?\? *bar\) *&& *baz;/;
|
||||
|
||||
let obfuscatedCode: string;
|
||||
|
||||
beforeEach(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/nullish-coalescing-support.js');
|
||||
|
||||
obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should support nullish coalescing operator', () => {
|
||||
assert.match(obfuscatedCode, regExp);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Numeric separators support', () => {
|
||||
const regExp: RegExp = /const foo *= *0x64;/;
|
||||
|
||||
let obfuscatedCode: string;
|
||||
|
||||
beforeEach(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/numeric-separators-support.js');
|
||||
|
||||
obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should support numeric separators', () => {
|
||||
assert.match(obfuscatedCode, regExp);
|
||||
});
|
||||
});
|
||||
|
||||
describe('mangled identifier names generator', () => {
|
||||
const regExp: RegExp = /var c *= *0x1/;
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export * as foo from 'bar';
|
||||
@@ -0,0 +1 @@
|
||||
(foo ?? bar) && baz;
|
||||
@@ -0,0 +1 @@
|
||||
const foo = 1_0_0;
|
||||
Reference in New Issue
Block a user