Skip to content

Commit

Permalink
minor fixes found from issues
Browse files Browse the repository at this point in the history
  • Loading branch information
5saviahv committed Jun 1, 2024
1 parent d3f5d7b commit 9c37fa8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion adm-zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ module.exports = function (/**String*/ input, /** object */ options) {
// prepare new entry
if (!update) {
entry = new ZipEntry();
entry.entryName = entryName;
entry.entryName = Utils.canonical(entryName);

This comment has been minimized.

Copy link
@skoniks

skoniks Jun 5, 2024

Contributor

#

}
entry.comment = comment || "";

Expand Down Expand Up @@ -464,6 +464,8 @@ module.exports = function (/**String*/ input, /** object */ options) {

entry.setData(content);
if (!update) _zip.setEntry(entry);

return entry;
},

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"url": "https://github.com/cthackers/adm-zip.git"
},
"engines": {
"node": ">=6.0"
"node": ">=12.0"
},
"devDependencies": {
"chai": "^4.3.4",
Expand Down
3 changes: 2 additions & 1 deletion zipEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module.exports = function (/*Buffer*/ input) {
_extra = Buffer.alloc(0);

function getCompressedDataFromZip() {
if (!input || !Buffer.isBuffer(input)) {
//if (!input || !Buffer.isBuffer(input)) {
if (!input || !(input instanceof Uint8Array)) {

This comment has been minimized.

Copy link
@nima-ap

nima-ap Jun 18, 2024

Hi
Why was this change introduced? I believe this is leading to a break of the .getData() API on a ZipEntry as it is no longer resolving to true even when the buffer is valid. Why does the Buffer have to be a Uint8Array?
In my case, input is simply of type Buffer in the runtime.

This comment has been minimized.

Copy link
@nima-ap

nima-ap Jun 18, 2024

I took a deeper look at the NodeJS specification and it seems like all Buffers indeed inherit UInt8Array so this code is not faulty.

The issue at hand is actually stemming from Jest it seems: jestjs/jest#4422
With the fix being: jestjs/jest#4422 (comment)

return Buffer.alloc(0);
}
_centralHeader.loadLocalHeaderFromBinary(input);
Expand Down

0 comments on commit 9c37fa8

Please sign in to comment.