mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Fixed identifiers prefix generation for obfuscateMultiple method
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user