Skip to content

Commit

Permalink
Conditionally support brotli
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewBarba committed Mar 16, 2021
1 parent 8a52665 commit a2db977
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/compression.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ exports.compress = (input,headers) => {
const acceptEncodingHeader = headers['accept-encoding'] || ''
const acceptableEncodings = new Set(acceptEncodingHeader.toLowerCase().split(',').map(str => str.trim()))

// Handle Brotli compression
if (acceptableEncodings.has('br')) {
// Handle Brotli compression (Only supported in Node v10 and later)
if (acceptableEncodings.has('br') && typeof zlib.brotliCompressSync === 'function') {
return {
data: zlib.brotliCompressSync(input),
contentEncoding: 'br'
Expand Down

0 comments on commit a2db977

Please sign in to comment.