Skip to content

Commit 36add2f

Browse files
authoredJun 22, 2020
Merge pull request #197 from pwoldberg/fix-comment
Get comment from centralDirectory
2 parents d427d86 + 11587a4 commit 36add2f

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed
 

‎lib/Open/directory.js

+5
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ module.exports = function centralDirectory(source, options) {
141141
vars.offsetToStartOfCentralDirectory += startOffset;
142142
}
143143
})
144+
.then(function() {
145+
return endDir.pull(vars.commentLength).then(function(comment) {
146+
vars.comment = comment.toString('utf8');
147+
});
148+
})
144149
.then(function() {
145150
source.stream(vars.offsetToStartOfCentralDirectory).pipe(records);
146151

‎test/openComment.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
3+
var test = require('tap').test;
4+
var path = require('path');
5+
var unzip = require('../');
6+
7+
8+
test("get comment out of a zip", function (t) {
9+
var archive = path.join(__dirname, '../testData/compressed-comment/archive.zip');
10+
11+
unzip.Open.file(archive)
12+
.then(function(d) {
13+
t.equal('Zipfile has a comment', d.comment);
14+
t.end();
15+
});
16+
});
468 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node.js rocks

0 commit comments

Comments
 (0)
Please sign in to comment.