netlify-headers-parser
Advanced tools
Comparing version 1.0.1 to 1.1.0
{ | ||
"name": "netlify-headers-parser", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Parses Netlify headers into a JavaScript object representation", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -1,2 +0,2 @@ | ||
const { inspect } = require('util') | ||
const { inspect, isDeepStrictEqual } = require('util') | ||
@@ -20,3 +20,3 @@ // Merge headers from `_headers` with the ones from `netlify.toml`. | ||
validateArray(configHeaders) | ||
return [...fileHeaders, ...configHeaders] | ||
return [...fileHeaders, ...configHeaders].filter(isUniqueHeader) | ||
} | ||
@@ -30,2 +30,10 @@ | ||
// Remove duplicates. This is especially likely considering `fileHeaders` might | ||
// have been previously merged to `configHeaders`, which happens when | ||
// `netlifyConfig.headers` is modified by plugins. | ||
// The latest duplicate value is the one kept. | ||
const isUniqueHeader = function (header, index, headers) { | ||
return !headers.slice(index + 1).some((otherHeader) => isDeepStrictEqual(header, otherHeader)) | ||
} | ||
module.exports = { mergeHeaders } |
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
12987
248