Skip to content

Commit

Permalink
Allow decompress option for non-deflate compressed entries
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Apr 28, 2023
1 parent 96f0eb5 commit 5e468b8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ ZipFile.prototype.openReadStream = function(entry, options, callback) {
}
}
if (options.decompress != null) {
if (!entry.isCompressed()) {
if (entry.compressionMethod === 0) {
throw new Error("options.decompress can only be specified for compressed entries");
}
if (!(options.decompress === false || options.decompress === true)) {
Expand Down Expand Up @@ -520,8 +520,10 @@ ZipFile.prototype.openReadStream = function(entry, options, callback) {
} else if (entry.compressionMethod === 8) {
// 8 - The file is Deflated
decompress = options.decompress != null ? options.decompress : true;
} else {
} else if (options.decompress == null || options.decompress) {
return callback(new Error("unsupported compression method: " + entry.compressionMethod));
} else {
decompress = false;
}
var fileDataStart = localFileHeaderEnd;
var fileDataEnd = fileDataStart + entry.compressedSize;
Expand Down

0 comments on commit 5e468b8

Please sign in to comment.