Skip to content

Commit

Permalink
fix: correct brotli options format (#165)
Browse files Browse the repository at this point in the history
* fix: correct brotli options format

3d205cd 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
  • Loading branch information
patrickhulce authored Jan 26, 2023
1 parent 41af9e8 commit af3da29
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion __tests__/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
4 changes: 3 additions & 1 deletion lib/encodings.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ Encodings.encodingMethodDefaultOptions = {
gzip: {},
deflate: {},
br: {
[zlib.constants.BROTLI_PARAM_QUALITY]: 4
params: {
[zlib.constants.BROTLI_PARAM_QUALITY]: 4
}
}
}

Expand Down

0 comments on commit af3da29

Please sign in to comment.