diff --git a/zipFile.js b/zipFile.js index 0c4360b..c3026b4 100644 --- a/zipFile.js +++ b/zipFile.js @@ -271,7 +271,12 @@ module.exports = function (/*String|Buffer*/input, /*Number*/inputType) { entry.header.offset = dindex; // data header var dataHeader = entry.header.dataHeaderToBinary(); - var postHeader = Buffer.from(name); + var postHeader; + try { + postHeader = Buffer.alloc(name.length, name); // using alloc will work on node 5.x+ + } catch(e){ + postHeader = new Buffer(name); // use deprecated method if alloc fails... + } var dataLength = dataHeader.length + postHeader.length + compressedData.length; dindex += dataLength;