Skip to content

Commit

Permalink
Revert "Replace accepts with negotiator"
Browse files Browse the repository at this point in the history
  • Loading branch information
bjohansebas authored Oct 25, 2024
1 parent d3560e0 commit 1e6e2bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @private
*/

var Negotiator = require('negotiator')
var accepts = require('accepts')
var Buffer = require('safe-buffer').Buffer
var bytes = require('bytes')
var compressible = require('compressible')
Expand Down Expand Up @@ -174,8 +174,13 @@ function compression (options) {
}

// compression method
var negotiator = new Negotiator(req)
var method = negotiator.encoding(['gzip', 'deflate', 'identity'], ['gzip'])
var accept = accepts(req)
var method = accept.encoding(['gzip', 'deflate', 'identity'])

// we really don't prefer deflate
if (method === 'deflate' && accept.encoding(['gzip'])) {
method = accept.encoding(['gzip', 'identity'])
}

// negotiation failed
if (!method || method === 'identity') {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"license": "MIT",
"repository": "expressjs/compression",
"dependencies": {
"accepts": "~1.3.8",
"bytes": "3.1.2",
"compressible": "~2.0.18",
"debug": "2.6.9",
"negotiator": "~0.6.4",
"on-headers": "~1.0.2",
"safe-buffer": "5.2.1",
"vary": "~1.1.2"
Expand Down

0 comments on commit 1e6e2bc

Please sign in to comment.