diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b02121..e9f6e69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## 1.12.1 (2024-00-00) - `deleteFile`: Remove unnecessary file existence checks +- `joinFilePath`: Responding to parent dir paths +- cleanup: Remove redundant codes ## 1.12.0 (2024-04-12) diff --git a/lib/index.ts b/lib/index.ts index b2c82dd..bc899a2 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -88,7 +88,7 @@ export default class FsMan { return FsMan.toValidFilePath(win32.join(...paths), true); } - return FsMan.toValidFilePath(paths.join('/'), false); + return FsMan.toValidFilePath(posix.join(...paths), false); } static getFilePathLevel(filePath: string): number { diff --git a/test/common.spec.ts b/test/common.spec.ts index ab2ed6c..ed1ebb1 100644 --- a/test/common.spec.ts +++ b/test/common.spec.ts @@ -67,10 +67,15 @@ describe('fsman', () => { it('joinFilePath', (done) => { assert.strictEqual(joinFilePath(true, 'C:\\', 'Windows', 'System32'), 'C:\\Windows\\System32'); + assert.strictEqual( + joinFilePath(true, 'C:\\', 'Windows', '..', 'System32', 'Test.txt'), + 'C:\\System32\\Test.txt' + ); assert.strictEqual(joinFilePath(true, 'Users', 'test'), '\\Users\\test'); assert.strictEqual(joinFilePath(true, 'C:\\Users\\test'), 'C:\\Users\\test'); assert.strictEqual(joinFilePath(false, '/home', 'user', 'Desktop'), '/home/user/Desktop'); assert.strictEqual(joinFilePath(false, 'home', '/user', '.bashrc'), '/home/user/.bashrc'); + assert.strictEqual(joinFilePath(false, 'home', '/user', '..', '.bashrc'), '/home/.bashrc'); done(); });