Skip to content

Commit 063cbc8

Browse files
authored
Merge pull request #493 from 5saviahv/issues
minor fixes found from issues
2 parents d3f5d7b + 3fbc83c commit 063cbc8

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

adm-zip.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ module.exports = function (/**String*/ input, /** object */ options) {
429429
// prepare new entry
430430
if (!update) {
431431
entry = new ZipEntry();
432-
entry.entryName = entryName;
432+
entry.entryName = Utils.canonical(entryName);
433433
}
434434
entry.comment = comment || "";
435435

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

465465
entry.setData(content);
466466
if (!update) _zip.setEntry(entry);
467+
468+
return entry;
467469
},
468470

469471
/**

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"url": "https://github.com/cthackers/adm-zip.git"
3838
},
3939
"engines": {
40-
"node": ">=6.0"
40+
"node": ">=12.0"
4141
},
4242
"devDependencies": {
4343
"chai": "^4.3.4",

test/mocha.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,16 @@ describe("adm-zip", () => {
218218
fs.unlinkSync("./text.txt");
219219
});
220220

221+
it("passes issue-438-AddFile with windows path sepator", () => {
222+
const zip = new Zip();
223+
zip.addFile("foo\\bar.txt", "test", "test");
224+
zip.extractAllTo(destination);
225+
226+
const files = walk(destination);
227+
228+
expect(files.sort()).to.deep.equal([pth.normalize("./test/xxx/foo/bar.txt")].sort());
229+
});
230+
221231
it("testing noSort option", () => {
222232
const content = "test";
223233
const comment = "comment";

zipEntry.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ module.exports = function (/*Buffer*/ input) {
1212
_extra = Buffer.alloc(0);
1313

1414
function getCompressedDataFromZip() {
15-
if (!input || !Buffer.isBuffer(input)) {
15+
//if (!input || !Buffer.isBuffer(input)) {
16+
if (!input || !(input instanceof Uint8Array)) {
1617
return Buffer.alloc(0);
1718
}
1819
_centralHeader.loadLocalHeaderFromBinary(input);

0 commit comments

Comments
 (0)