Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor fixes found from issues #493

Merged
merged 2 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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