Fixed bug in inflate options logic

This commit is contained in:
Vitaly Puzrin 2014-03-12 02:46:29 +04:00
parent 7701d13f4b
commit 5370c1382d

View file

@ -88,15 +88,23 @@ var Inflate = function(options) {
this.options = utils.assign({
chunkSize: 16384,
windowBits: 15 + 32 // By default - autodetect deflate/gzip
windowBits: 15
}, options || {});
var opt = this.options;
if (opt.raw && (opt.windowBits > 0)) {
// check `raw` if `windowBits` NOT defined directly,
// or we will get bug because of autodetect
if (opt.raw && (opt.windowBits > 0) && (opt.windowBits < 16)) {
opt.windowBits = -opt.windowBits;
}
// If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate
if ((opt.windowBits > 0) && (opt.windowBits < 16) &&
!(options && options.windowBits)) {
opt.windowBits += 32;
}
this.err = 0; // error code, if happens (0 = Z_OK)
this.msg = ''; // error message
this.ended = false; // used to avoid multiple onEnd() calls