Skip to content

Commit

Permalink
Merge pull request #493 from 5saviahv/issues
Browse files Browse the repository at this point in the history
minor fixes found from issues
  • Loading branch information
5saviahv authored Jun 1, 2024
2 parents d3f5d7b + 3fbc83c commit 063cbc8
Show file tree
Hide file tree
Showing 4 changed files with 16 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);
}
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
10 changes: 10 additions & 0 deletions test/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,16 @@ describe("adm-zip", () => {
fs.unlinkSync("./text.txt");
});

it("passes issue-438-AddFile with windows path sepator", () => {
const zip = new Zip();
zip.addFile("foo\\bar.txt", "test", "test");
zip.extractAllTo(destination);

const files = walk(destination);

expect(files.sort()).to.deep.equal([pth.normalize("./test/xxx/foo/bar.txt")].sort());
});

it("testing noSort option", () => {
const content = "test";
const comment = "comment";
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)) {
return Buffer.alloc(0);
}
_centralHeader.loadLocalHeaderFromBinary(input);
Expand Down

0 comments on commit 063cbc8

Please sign in to comment.