Fixed identifiers prefix generation for obfuscateMultiple method

This commit is contained in:
sanex3339
2020-03-16 11:53:45 +03:00
parent 5eb2f743d0
commit bbc672e80e
10 changed files with 90 additions and 19 deletions
@@ -903,8 +903,8 @@ describe('JavaScriptObfuscator', () => {
describe('obfuscateMultiple', () => {
describe('multiple source codes', () => {
const regExp1: RegExp = /var _0x(\w){4,6} *= *0x1;/;
const regExp2: RegExp = /var _0x(\w){4,6} *= *'abc';/;
const regExp1: RegExp = /var a0_0x(\w){4,6} *= *0x1;/;
const regExp2: RegExp = /var a1_0x(\w){4,6} *= *'abc';/;
let obfuscatedCode1: string;
let obfuscatedCode2: string;
+36
View File
@@ -123,4 +123,40 @@ describe('Utils', () => {
});
});
});
describe('getIdentifiersPrefixForMultipleSources', () => {
describe('Variant #1: should get identifiers prefix for identifiers prefix from options', () => {
const expectedIdentifiersPrefix: string = 'foo1';
let identifiersPrefix: string;
before(() => {
identifiersPrefix = Utils.getIdentifiersPrefixForMultipleSources(
'foo',
1
);
});
it('should return correct identifiers prefix', () => {
assert.equal(identifiersPrefix, expectedIdentifiersPrefix);
});
});
describe('Variant #2: should get identifiers prefix for base identifiers prefix for multiple sources', () => {
const expectedIdentifiersPrefix: string = 'a1';
let identifiersPrefix: string;
before(() => {
identifiersPrefix = Utils.getIdentifiersPrefixForMultipleSources(
undefined,
1
);
});
it('should return correct identifiers prefix', () => {
assert.equal(identifiersPrefix, expectedIdentifiersPrefix);
});
});
});
});