-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: correct brotli options format #165
Conversation
3d205cd didn't actually fix the default compression issue described in koajs#121 because the zlib format expects quality to be inside [an option called `params`](https://nodejs.org/api/zlib.html#class-brotlioptions)
Codecov Report
@@ Coverage Diff @@
## master #165 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 88 88
Branches 32 32
=========================================
Hits 88 88
Continue to review full report at Codecov.
|
@@ -89,7 +89,9 @@ Encodings.encodingMethodDefaultOptions = { | |||
gzip: {}, | |||
deflate: {}, | |||
br: { | |||
[zlib.constants.BROTLI_PARAM_QUALITY]: 4 | |||
params: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this change,
Lines 41 to 42 in fc8fca0
...Encodings.encodingMethodDefaultOptions[encoding], | |
...(options[encoding] || {}) |
As the PR is now, options['br']
will shallow merge, so if a consumer provides
koaCompress({
br: {
params: {
[zlib.constants.BROTLI_PARAM_MODE]: zlib.constants.BROTLI_MODE_TEXT
},
},
});
I think the final object sent to zlib.createBrotliCompress
ends up being
{
params: {
[zlib.constants.BROTLI_PARAM_MODE]: zlib.constants.BROTLI_MODE_TEXT,
// the koa-compress default of [zlib.constants.BROTLI_PARAM_QUALITY]: 4 is no longer passed in
},
}
It can go either way but users might expect the brotli options to deep merge here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the final object sent to zlib.createBrotliCompress ends up being
Correct.
users might expect the brotli options to deep merge here
True, I'll happily defer to maintainers here on what the koa community expects.
@jonathanong friendly ping on this :) |
We should prob also set |
When there'll be a new release ship this fix? |
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
Example Test Sever
Before
After