mirror of
https://github.com/0x5eal/rbxts-pako.git
synced 2025-04-20 03:43:49 +01:00
Fixed ungzip: force window size when not set, because autodetect impossible
This commit is contained in:
parent
21c21df425
commit
07173737fc
2 changed files with 12 additions and 2 deletions
|
@ -100,6 +100,16 @@ var Inflate = function(options) {
|
||||||
opt.windowBits += 32;
|
opt.windowBits += 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gzip header has no info about windows size, we can do autodetect only
|
||||||
|
// for deflate. So, if window size not set, force it to max when gzip possible
|
||||||
|
if ((opt.windowBits > 15) && (opt.windowBits < 48)) {
|
||||||
|
// bit 3 (16) -> gzipped data
|
||||||
|
// bit 4 (32) -> autodetect gzip/deflate
|
||||||
|
if ((opt.windowBits & 15) === 0) {
|
||||||
|
opt.windowBits |= 15;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.err = 0; // error code, if happens (0 = Z_OK)
|
this.err = 0; // error code, if happens (0 = Z_OK)
|
||||||
this.msg = ''; // error message
|
this.msg = ''; // error message
|
||||||
this.ended = false; // used to avoid multiple onEnd() calls
|
this.ended = false; // used to avoid multiple onEnd() calls
|
||||||
|
|
|
@ -28,12 +28,12 @@ describe('Inflate ungzip', function () {
|
||||||
// TODO: Investigate, why ungzip does not autodetect window size and
|
// TODO: Investigate, why ungzip does not autodetect window size and
|
||||||
// require to set windowBits directly
|
// require to set windowBits directly
|
||||||
|
|
||||||
it.skip('with autodetect', function(done) {
|
it('with autodetect', function(done) {
|
||||||
testInflate(samples, {}, { gzip: true }, done);
|
testInflate(samples, {}, { gzip: true }, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with method set directly', function(done) {
|
it('with method set directly', function(done) {
|
||||||
testInflate(samples, { windowBits: 15 + 16 }, { gzip: true }, done);
|
testInflate(samples, { windowBits: 16 }, { gzip: true }, done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue