mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
make forward slash in output path consistent
This commit is contained in:
@@ -61,6 +61,12 @@ export class ObfuscatedCodeFileUtils {
|
||||
if (isDirectoryRawInputPath) {
|
||||
if (isDirectoryRawOutputPath) {
|
||||
const parsedNormalizedFilePath: path.ParsedPath = path.parse(normalizedFilePath);
|
||||
|
||||
// Make ending with "/" consistent
|
||||
if (!parsedNormalizedFilePath.dir.endsWith('/') && this.inputPath.endsWith('/')) {
|
||||
parsedNormalizedFilePath.dir += '/';
|
||||
}
|
||||
|
||||
const baseOutputPath: string = path.join(
|
||||
parsedNormalizedFilePath.dir.replace(this.inputPath, ''),
|
||||
parsedNormalizedFilePath.base
|
||||
|
||||
@@ -48,6 +48,7 @@ import './unit-tests/utils/CryptUtilsStringArray.spec';
|
||||
import './unit-tests/utils/EscapeSequenceEncoder.spec';
|
||||
import './unit-tests/utils/LevelledTopologicalSorter.spec';
|
||||
import './unit-tests/utils/NumberUtils.spec';
|
||||
import './unit-tests/utils/ObfuscatedCodeFileUtils.spec'
|
||||
import './unit-tests/utils/RandomGenerator.spec';
|
||||
import './unit-tests/utils/StringUtils.spec';
|
||||
import './unit-tests/utils/Utils.spec';
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { expect } from 'chai';
|
||||
import { ObfuscatedCodeFileUtils } from '../../../src/cli/utils/ObfuscatedCodeFileUtils';
|
||||
|
||||
describe('ObfuscatedCodeFileUtils', () => {
|
||||
let util: ObfuscatedCodeFileUtils;
|
||||
|
||||
beforeEach(() => {
|
||||
util = new ObfuscatedCodeFileUtils('src/cli/', {
|
||||
output: 'src/cli/dist',
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle input path ending (or not ending) with forward slash', () => {
|
||||
const result = util.getOutputCodePath('src/cli/app.js');
|
||||
expect(result).equals('src/cli/dist/app.js');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user