@hapi/accept
Advanced tools
Comparing version 4.0.0 to 4.0.1
@@ -82,7 +82,7 @@ 'use strict'; | ||
const lowers = Object.create(null); | ||
const lowers = new Map(); | ||
if (preferences) { | ||
for (let i = 0; i < preferences.length; ++i) { | ||
const preference = preferences[i]; | ||
lowers[preference.toLowerCase()] = { orig: preference, pos: i }; | ||
lowers.set(preference.toLowerCase(), { orig: preference, pos: i }); | ||
} | ||
@@ -95,3 +95,3 @@ } | ||
const selections = []; | ||
const map = {}; | ||
const map = new Set(); | ||
@@ -117,5 +117,5 @@ for (let i = 0; i < parts.length; ++i) { | ||
if (options.equivalents && | ||
options.equivalents[token]) { | ||
options.equivalents.has(token)) { | ||
token = options.equivalents[token]; | ||
token = options.equivalents.get(token); | ||
} | ||
@@ -131,8 +131,8 @@ | ||
if (preferences && | ||
lowers[token]) { | ||
lowers.has(token)) { | ||
selection.pref = lowers[token].pos; | ||
selection.pref = lowers.get(token).pos; | ||
} | ||
map[selection.token] = selection; | ||
map.add(selection.token); | ||
@@ -146,3 +146,3 @@ // Parse q=value | ||
if (!value || | ||
(key !== 'q' && key !== 'Q')) { | ||
key !== 'q' && key !== 'Q') { | ||
@@ -177,3 +177,3 @@ throw Boom.badRequest(`Invalid ${options.type} header`); | ||
if (options.default && | ||
!map[options.default]) { | ||
!map.has(options.default)) { | ||
@@ -192,5 +192,5 @@ values.push(options.default); | ||
if (selection === '*') { | ||
for (const preference of Object.keys(lowers)) { | ||
if (!map[preference]) { | ||
preferred.push(lowers[preference].orig); | ||
for (const [preference, value] of lowers) { | ||
if (!map.has(preference)) { | ||
preferred.push(value.orig); | ||
} | ||
@@ -201,4 +201,4 @@ } | ||
const lower = selection.toLowerCase(); | ||
if (lowers[lower]) { | ||
preferred.push(lowers[lower].orig); | ||
if (lowers.has(lower)) { | ||
preferred.push(lowers.get(lower).orig); | ||
} | ||
@@ -205,0 +205,0 @@ } |
@@ -15,6 +15,6 @@ 'use strict'; | ||
default: 'identity', | ||
equivalents: { | ||
'x-compress': 'compress', | ||
'x-gzip': 'gzip' | ||
} | ||
equivalents: new Map([ | ||
['x-compress', 'compress'], | ||
['x-gzip', 'gzip'] | ||
]) | ||
}, | ||
@@ -21,0 +21,0 @@ language: { |
{ | ||
"name": "@hapi/accept", | ||
"description": "HTTP Accept-* headers parsing", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"repository": "git://github.com/hapijs/accept", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23577