mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Added optional-chaining support
This commit is contained in:
@@ -2,6 +2,7 @@ Change Log
|
||||
|
||||
v1.10.0
|
||||
---
|
||||
* **Feature:** Optional chaining support!
|
||||
* Improved `disableConsoleOutput` template. https://github.com/javascript-obfuscator/javascript-obfuscator/issues/691
|
||||
|
||||
v1.9.0
|
||||
|
||||
@@ -1089,7 +1089,7 @@ Performance will slightly slower than without obfuscation
|
||||
|
||||
### What javascript versions are supported?
|
||||
|
||||
`es3`, `es5`, `es2015`, `es2016` and `es2017`
|
||||
`es3`, `es5`, `es2015`, `es2016`, `es2017`, `es2018`, `es2019` and partially `es2020`
|
||||
|
||||
### I want to use feature that described in `README.md` but it's not working!
|
||||
|
||||
|
||||
Vendored
+7
-7
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -43,6 +43,9 @@
|
||||
"string-template": "1.0.0",
|
||||
"tslib": "2.0.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"eslint-scope/esrecurse/estraverse": "5.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chai": "4.2.12",
|
||||
"@types/chance": "1.1.0",
|
||||
|
||||
@@ -682,6 +682,32 @@ describe('JavaScriptObfuscator', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Optional chaining support', () => {
|
||||
const regExp: RegExp = new RegExp(
|
||||
'const _0x(\\w){4,6} *= *{ *' +
|
||||
'\'bar\': *\\(\\) *=> *{} *' +
|
||||
'}; *' +
|
||||
'_0x(\\w){4,6}\\?\\.\\[\'bar\']\\?\\.\\(\\);'
|
||||
);
|
||||
|
||||
let obfuscatedCode: string;
|
||||
|
||||
beforeEach(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/optional-chaining-support.js');
|
||||
|
||||
obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should support optional chaining', () => {
|
||||
assert.match(obfuscatedCode, regExp);
|
||||
});
|
||||
});
|
||||
|
||||
describe('mangled identifier names generator', () => {
|
||||
const regExp: RegExp = /var c *= *0x1/;
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
function test() {
|
||||
const foo = {
|
||||
bar: () => {}
|
||||
};
|
||||
|
||||
foo?.bar?.();
|
||||
}
|
||||
@@ -2145,12 +2145,12 @@ esrecurse@^4.1.0:
|
||||
dependencies:
|
||||
estraverse "^4.1.0"
|
||||
|
||||
estraverse@5.2.0, estraverse@^5.2.0:
|
||||
estraverse@5.2.0, estraverse@^4.1.0, estraverse@^5.2.0:
|
||||
version "5.2.0"
|
||||
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.2.0.tgz#307df42547e6cc7324d3cf03c155d5cdb8c53880"
|
||||
integrity sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==
|
||||
|
||||
estraverse@^4.1.0, estraverse@^4.1.1:
|
||||
estraverse@^4.1.1:
|
||||
version "4.3.0"
|
||||
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d"
|
||||
integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==
|
||||
|
||||
Reference in New Issue
Block a user