diff --git a/lib/header.js b/lib/header.js index ced9e2b..b0478a3 100755 --- a/lib/header.js +++ b/lib/header.js @@ -103,6 +103,7 @@ internals.parse = function (raw, preferences, options) { const parts = header.split(','); const selections = []; const map = new Set(); + let applyDefault = true; for (let i = 0; i < parts.length; ++i) { const part = parts[i]; @@ -154,6 +155,10 @@ internals.parse = function (raw, preferences, options) { const score = parseFloat(value); if (score === 0) { + if (token === '*') { + applyDefault = false; + } + continue; } @@ -177,6 +182,7 @@ internals.parse = function (raw, preferences, options) { const values = selections.map((selection) => selection.token); if (options.default && + applyDefault && !map.has(options.default)) { values.push(options.default); diff --git a/test/encoding.js b/test/encoding.js index e2f5d23..fef1670 100755 --- a/test/encoding.js +++ b/test/encoding.js @@ -162,4 +162,10 @@ describe('encodings()', () => { const encodings = Accept.encodings('compress;q=0.5, gzip;q=1.0, identity;q=0'); expect(encodings).to.equal(['gzip', 'compress']); }); + + it('parses header (exclude identity as wildcard)', () => { + + const encodings = Accept.encodings('compress;q=0.5, gzip;q=1.0, *;q=0'); + expect(encodings).to.equal(['gzip', 'compress']); + }); });