From af3da29a07e2ee408294271ac71bb77b5ad9e54f Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Thu, 26 Jan 2023 13:27:35 -0600 Subject: [PATCH] fix: correct brotli options format (#165) * fix: correct brotli options format 3d205cd88b48980c840b8b8f889676c2b3a4c6e2 didn't actually fix the default compression issue described in #121 because the zlib format expects quality to be inside [an option called `params`](https://nodejs.org/api/zlib.html#class-brotlioptions) * tests: update defaults test * chore: remove trailing whitespace --- __tests__/defaults.js | 2 +- lib/encodings.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/__tests__/defaults.js b/__tests__/defaults.js index 34e7d6f..42f3024 100644 --- a/__tests__/defaults.js +++ b/__tests__/defaults.js @@ -8,5 +8,5 @@ test('default brotli param quality should be 4', () => { const middleware = createCompressMiddleware() assert(Array.isArray(middleware.preferredEncodings)) assert(middleware.encodingOptions) - assert.strictEqual(middleware.encodingOptions.br[zlib.constants.BROTLI_PARAM_QUALITY], 4) + assert.strictEqual(middleware.encodingOptions.br.params[zlib.constants.BROTLI_PARAM_QUALITY], 4) }) diff --git a/lib/encodings.js b/lib/encodings.js index 32d301b..19b97fb 100644 --- a/lib/encodings.js +++ b/lib/encodings.js @@ -89,7 +89,9 @@ Encodings.encodingMethodDefaultOptions = { gzip: {}, deflate: {}, br: { - [zlib.constants.BROTLI_PARAM_QUALITY]: 4 + params: { + [zlib.constants.BROTLI_PARAM_QUALITY]: 4 + } } }