Fixed wrong name of obfuscated files when input directory path is the . symbol

https://github.com/javascript-obfuscator/javascript-obfuscator/issues/816
This commit is contained in:
sanex
2020-11-20 10:21:11 +03:00
parent 1409c02f45
commit 576c50e755
7 changed files with 67 additions and 5 deletions
+4
View File
@@ -1,5 +1,9 @@
Change Log
v2.9.3
---
* **CLI**: Fixed wrong name of obfuscated files when input directory path is the `.` symbol. https://github.com/javascript-obfuscator/javascript-obfuscator/issues/816
v2.9.2
---
* Ignore object expressions as body of arrow function expression when `transformObjectKeys` option is enabled. Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/813
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "javascript-obfuscator",
"version": "2.9.2",
"version": "2.9.3",
"description": "JavaScript obfuscator",
"keywords": [
"obfuscator",
+5 -1
View File
@@ -60,7 +60,11 @@ export class ObfuscatedCodeWriter {
if (isDirectoryRawInputPath) {
if (isDirectoryRawOutputPath) {
const baseOutputPath: string = normalizedFilePath.replace(this.inputPath, '');
const parsedNormalizedFilePath: path.ParsedPath = path.parse(normalizedFilePath);
const baseOutputPath: string = path.join(
parsedNormalizedFilePath.dir.replace(this.inputPath, ''),
parsedNormalizedFilePath.base
);
return path.join(normalizedRawOutputPath, baseOutputPath);
} else {
@@ -197,6 +197,60 @@ describe('ObfuscatedCodeWriter', () => {
assert.equal(outputCodePath, expectedOutputCodePath);
});
});
describe('Variant #5: input directory name with dot only', () => {
const inputPath: string = path.join('test-input.js');
const rawInputPath: string = path.join('.');
const rawOutputPath: string = path.join(tmpDirectoryPath, 'output');
const expectedOutputCodePath: string = path.join(
tmpDirectoryPath,
'output',
'test-input.js'
);
let outputCodePath: string;
before(() => {
const obfuscatedCodeWriter: ObfuscatedCodeWriter = new ObfuscatedCodeWriter(
rawInputPath,
{
output: rawOutputPath
}
);
outputCodePath = obfuscatedCodeWriter.getOutputCodePath(inputPath);
});
it('should return output path that contains raw output path and actual file input path', () => {
assert.equal(outputCodePath, expectedOutputCodePath);
});
});
describe('Variant #6: input directory name with dot and slash only', () => {
const inputPath: string = path.join('test-input.js');
const rawInputPath: string = path.join('./');
const rawOutputPath: string = path.join(tmpDirectoryPath, 'output');
const expectedOutputCodePath: string = path.join(
tmpDirectoryPath,
'output',
'test-input.js'
);
let outputCodePath: string;
before(() => {
const obfuscatedCodeWriter: ObfuscatedCodeWriter = new ObfuscatedCodeWriter(
rawInputPath,
{
output: rawOutputPath
}
);
outputCodePath = obfuscatedCodeWriter.getOutputCodePath(inputPath);
});
it('should return output path that contains raw output path and actual file input path', () => {
assert.equal(outputCodePath, expectedOutputCodePath);
});
});
});
describe('Variant #5: Win32 environment', () => {