Skip to content

Commit

Permalink
fix: joinFilePath: esponding to parent dir paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jooy2 committed May 14, 2024
1 parent 5d881c0 commit 3b530fb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions test/common.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down

0 comments on commit 3b530fb

Please sign in to comment.