Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

netlify-headers-parser

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

netlify-headers-parser - npm Package Compare versions

Comparing version 3.0.1 to 4.0.0

src/for_regexp.js

3

package.json
{
"name": "netlify-headers-parser",
"version": "3.0.1",
"version": "4.0.0",
"description": "Parses Netlify headers into a JavaScript object representation",

@@ -33,2 +33,3 @@ "main": "src/index.js",

"dependencies": {
"escape-string-regexp": "^4.0.0",
"is-plain-obj": "^3.0.0",

@@ -35,0 +36,0 @@ "map-obj": "^4.2.1",

@@ -9,3 +9,3 @@ const { parseFileHeaders } = require('./line_parser')

// and validate those.
const parseAllHeaders = async function ({ headersFiles = [], netlifyConfigPath, configHeaders = [] }) {
const parseAllHeaders = async function ({ headersFiles = [], netlifyConfigPath, configHeaders = [], minimal = false }) {
const [

@@ -15,6 +15,8 @@ { headers: fileHeaders, errors: fileParseErrors },

] = await Promise.all([getFileHeaders(headersFiles), getConfigHeaders(netlifyConfigPath)])
const { headers: normalizedFileHeaders, errors: fileNormalizeErrors } = normalizeHeaders(fileHeaders)
const { headers: normalizedConfigParseHeaders, errors: configParseNormalizeErrors } =
normalizeHeaders(parsedConfigHeaders)
const { headers: normalizedConfigHeaders, errors: configNormalizeErrors } = normalizeHeaders(configHeaders)
const { headers: normalizedFileHeaders, errors: fileNormalizeErrors } = normalizeHeaders(fileHeaders, minimal)
const { headers: normalizedConfigParseHeaders, errors: configParseNormalizeErrors } = normalizeHeaders(
parsedConfigHeaders,
minimal,
)
const { headers: normalizedConfigHeaders, errors: configNormalizeErrors } = normalizeHeaders(configHeaders, minimal)
const { headers, errors: mergeErrors } = mergeHeaders({

@@ -21,0 +23,0 @@ fileHeaders: normalizedFileHeaders,

const isPlainObj = require('is-plain-obj')
const mapObj = require('map-obj')
const { getForRegExp } = require('./for_regexp')
const { splitResults } = require('./results')

@@ -9,3 +10,3 @@

// `netlify.toml` or `_headerss`.
const normalizeHeaders = function (headers) {
const normalizeHeaders = function (headers, minimal) {
if (!Array.isArray(headers)) {

@@ -16,7 +17,7 @@ const error = new TypeError(`Headers must be an array not: ${headers}`)

const results = headers.map(parseHeader).filter(Boolean)
const results = headers.map((header, index) => parseHeader(header, index, minimal)).filter(Boolean)
return splitResults(results)
}
const parseHeader = function (header, index) {
const parseHeader = function (header, index, minimal) {
if (!isPlainObj(header)) {

@@ -27,3 +28,3 @@ return new TypeError(`Header must be an object not: ${header}`)

try {
return parseHeaderObject(header)
return parseHeaderObject(header, minimal)
} catch (error) {

@@ -37,4 +38,4 @@ return new Error(`Could not parse header number ${index + 1}:

// Parse a single `headers` object
const parseHeaderObject = function ({ for: rawPath, values: rawValues }) {
const path = normalizePath(rawPath)
const parseHeaderObject = function ({ for: rawPath, values: rawValues }, minimal) {
const forPath = normalizePath(rawPath)

@@ -51,3 +52,7 @@ if (rawValues === undefined) {

return { for: path, values }
return {
for: forPath,
...(minimal || { forRegExp: getForRegExp(forPath) }),
values,
}
}

@@ -54,0 +59,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc