diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2024-02-07 21:53:32 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-07 21:53:32 +0530 |
commit | a32e7f0eb23fa17f5af2fc4c8abfd79762934244 (patch) | |
tree | f1c0a23a800974f8311dc45f044692b04868fb23 /cli | |
parent | e5ae142fbeb83ec5b335a0a3fcb7a564cbf65bd4 (diff) |
fix(node): handle brotli compression end chunk sizes (#22322)
Fixes https://github.com/denoland/deno/issues/22259
Diffstat (limited to 'cli')
-rw-r--r-- | cli/tests/unit_node/zlib_test.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/cli/tests/unit_node/zlib_test.ts b/cli/tests/unit_node/zlib_test.ts index fa94493c1..b61cd4d4f 100644 --- a/cli/tests/unit_node/zlib_test.ts +++ b/cli/tests/unit_node/zlib_test.ts @@ -14,6 +14,8 @@ import { } from "node:zlib"; import { Buffer } from "node:buffer"; import { createReadStream, createWriteStream } from "node:fs"; +import { Readable } from "node:stream"; +import { buffer } from "node:stream/consumers"; Deno.test("brotli compression sync", () => { const buf = Buffer.from("hello world"); @@ -155,3 +157,16 @@ Deno.test("zlib compression with an encoded string", { const decompressed = unzipSync(compressed); assertEquals(decompressed.toString(), "hello world"); }); + +Deno.test("brotli large chunk size", async () => { + const input = new Uint8Array(1000000); + for (let i = 0; i < input.length; i++) { + input[i] = Math.random() * 256; + } + const output = await buffer( + Readable.from([input]) + .pipe(createBrotliCompress()) + .pipe(createBrotliDecompress()), + ); + assertEquals(output.length, input.length); +}); |