Skip to content

Commit

Permalink
fix: support windows directory detect (#106)
Browse files Browse the repository at this point in the history
fix window file separator

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Bug Fixes**
- Improved directory detection in zip files to handle both backslashes
and forward slashes, ensuring better compatibility across different
operating systems.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: fengmk2 <[email protected]>
  • Loading branch information
grj001 and fengmk2 authored May 23, 2024
1 parent 7043a9c commit 122091b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/zip/uncompress_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ class ZipUncompressStream extends UncompressBaseStream {
entry.fileName = iconv.decode(entry.fileName, this._zipFileNameEncoding);
}
}
// directory file names end with '/'
const type = /\/$/.test(entry.fileName) ? 'directory' : 'file';
// directory file names end with '/' (for Linux and macOS) or '\' (for Windows)
const type = /[\\\/]$/.test(entry.fileName) ? 'directory' : 'file';
const name = entry.fileName = this[STRIP_NAME](entry.fileName, type);

const header = { name, type, yauzl: entry, mode };
Expand Down

0 comments on commit 122091b

Please sign in to comment.