netlify-headers-parser
Advanced tools
Comparing version 1.1.0 to 1.1.1
{ | ||
"name": "netlify-headers-parser", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Parses Netlify headers into a JavaScript object representation", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -75,8 +75,16 @@ const isPlainObj = require('is-plain-obj') | ||
if (typeof rawValue !== 'string') { | ||
throw new TypeError(`Header "${key}" value must be a string not: ${rawValue}`) | ||
const value = normalizeRawValue(key, rawValue) | ||
return [key, value] | ||
} | ||
const normalizeRawValue = function (key, rawValue) { | ||
if (typeof rawValue === 'string') { | ||
return normalizeMultipleValues(normalizeStringValue(rawValue)) | ||
} | ||
const value = normalizeMultipleValues(rawValue.trim()) | ||
return [key, value] | ||
if (Array.isArray(rawValue)) { | ||
return rawValue.map((singleValue, index) => normalizeArrayItemValue(`${key}[${index}]`, singleValue)).join(',') | ||
} | ||
throw new TypeError(`Header "${key}" value must be a string not: ${rawValue}`) | ||
} | ||
@@ -105,2 +113,14 @@ | ||
const normalizeArrayItemValue = function (key, singleValue) { | ||
if (typeof singleValue !== 'string') { | ||
throw new TypeError(`Header "${key}" value must be a string not: ${singleValue}`) | ||
} | ||
return normalizeStringValue(singleValue) | ||
} | ||
const normalizeStringValue = function (stringValue) { | ||
return stringValue.trim() | ||
} | ||
module.exports = { normalizeHeaders } |
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
13579
263