From 5506224f180d69cf2d32235b51f94090db87b2fe Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Tue, 16 Jan 2024 05:27:19 -0300 Subject: [PATCH] fix: Override Brotli compress default options (#26648) --- lib/util/compress.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/util/compress.ts b/lib/util/compress.ts index 4cd3e6a4b0cbd9..dd97c1aefbe6bc 100644 --- a/lib/util/compress.ts +++ b/lib/util/compress.ts @@ -1,11 +1,16 @@ import { promisify } from 'node:util'; -import zlib from 'node:zlib'; +import zlib, { constants } from 'node:zlib'; const brotliCompress = promisify(zlib.brotliCompress); const brotliDecompress = promisify(zlib.brotliDecompress); export async function compress(input: string): Promise { - const buf = await brotliCompress(input); + const buf = await brotliCompress(input, { + params: { + [constants.BROTLI_PARAM_MODE]: constants.BROTLI_MODE_TEXT, + [constants.BROTLI_PARAM_QUALITY]: 8, + }, + }); return buf.toString('base64'); }