content-security-policy-parser
Advanced tools
Comparing version 0.4.0 to 0.4.1
# Changelog | ||
## 0.4.1 - 2022-03-23 | ||
### Changed | ||
- Shrink package size slightly | ||
## 0.4.0 - 2020-12-22 | ||
@@ -4,0 +10,0 @@ |
"use strict"; | ||
module.exports = (policy) => policy.split(";").reduce((result, directive) => { | ||
const [directiveKey, ...directiveValue] = directive.trim().split(/\s+/g); | ||
if (directiveKey && | ||
!Object.prototype.hasOwnProperty.call(result, directiveKey)) { | ||
// Mutating `reduce`'s result is typically discouraged, but we do it here for performance. | ||
result[directiveKey] = directiveValue; | ||
} | ||
module.exports = (policy) => { | ||
const result = {}; | ||
policy.split(";").forEach((directive) => { | ||
const [directiveKey, ...directiveValue] = directive.trim().split(/\s+/g); | ||
if (directiveKey && | ||
!Object.prototype.hasOwnProperty.call(result, directiveKey)) { | ||
result[directiveKey] = directiveValue; | ||
} | ||
}); | ||
return result; | ||
}, {}); | ||
}; |
@@ -5,3 +5,3 @@ { | ||
"description": "Parse Content Security Policy directives.", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"license": "MIT", | ||
@@ -41,5 +41,5 @@ "keywords": [ | ||
"lint": "npm run lint:eslint && npm run lint:prettier", | ||
"lint:eslint": "eslint \"**/*.ts\"", | ||
"lint:prettier": "prettier --check \"**/*.{md,js,json,ts}\"", | ||
"format": "prettier --write \"**/*.{md,js,json,ts}\"", | ||
"lint:eslint": "eslint .", | ||
"lint:prettier": "prettier --check .", | ||
"format": "prettier --write .", | ||
"clean": "rm -rf dist", | ||
@@ -50,11 +50,11 @@ "build": "npm run clean && tsc", | ||
"devDependencies": { | ||
"@types/jest": "^26.0.19", | ||
"@typescript-eslint/eslint-plugin": "^4.11.0", | ||
"@typescript-eslint/parser": "^4.11.0", | ||
"eslint": "^7.16.0", | ||
"jest": "^26.6.3", | ||
"prettier": "^2.2.1", | ||
"ts-jest": "^26.4.4", | ||
"typescript": "^4.1.3" | ||
"@types/jest": "^27.4.1", | ||
"@typescript-eslint/eslint-plugin": "^5.16.0", | ||
"@typescript-eslint/parser": "^5.16.0", | ||
"eslint": "^8.11.0", | ||
"jest": "^27.5.1", | ||
"prettier": "^2.6.0", | ||
"ts-jest": "^27.1.3", | ||
"typescript": "^4.6.2" | ||
} | ||
} |
# Content Security Policy parser | ||
[![Build Status](https://travis-ci.org/helmetjs/content-security-policy-parser.svg?branch=master)](https://travis-ci.org/helmetjs/content-security-policy-parser) | ||
Take a Content Security Policy string and parse it. | ||
@@ -6,0 +4,0 @@ |
Sorry, the diff of this file is not supported yet
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
17
4144
24