content-security-policy-builder
Advanced tools
Comparing version 2.1.1 to 2.2.0
# Changelog | ||
## 2.2.0 - 2024-04-25 | ||
### Added | ||
- Added ECMAScript Module support | ||
### Removed | ||
- **Breaking:** Drop support for old Node versions. Node 18+ is now required | ||
## 2.1.1 - 2022-03-23 | ||
@@ -4,0 +14,0 @@ |
"use strict"; | ||
module.exports = function (_a) { | ||
var directives = _a.directives; | ||
var namesSeen = new Set(); | ||
var result = []; | ||
Object.keys(directives).forEach(function (originalName) { | ||
var name = originalName.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(); | ||
module.exports = ({ directives }) => { | ||
const namesSeen = new Set(); | ||
const result = []; | ||
Object.entries(directives).forEach(([originalName, value]) => { | ||
const name = originalName.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(); | ||
if (namesSeen.has(name)) { | ||
throw new Error("".concat(originalName, " is specified more than once")); | ||
throw new Error(`${originalName} is specified more than once`); | ||
} | ||
namesSeen.add(name); | ||
var value = directives[originalName]; | ||
if (Array.isArray(value)) { | ||
@@ -20,3 +18,3 @@ value = value.join(" "); | ||
if (value) { | ||
result.push("".concat(name, " ").concat(value)); | ||
result.push(`${name} ${value}`); | ||
} | ||
@@ -23,0 +21,0 @@ else if (value !== false) { |
@@ -5,3 +5,3 @@ { | ||
"description": "Build Content Security Policy directives.", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"license": "MIT", | ||
@@ -26,6 +26,15 @@ "keywords": [ | ||
"engines": { | ||
"node": ">=4.0.0" | ||
"node": ">=18.0.0" | ||
}, | ||
"sideEffects": false, | ||
"main": "./dist/index.js", | ||
"typings": "./dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.mjs", | ||
"default": "./dist/index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"files": [ | ||
@@ -35,4 +44,3 @@ "LICENSE", | ||
"CHANGELOG.md", | ||
"dist/index.js", | ||
"dist/index.d.ts" | ||
"dist" | ||
], | ||
@@ -47,15 +55,14 @@ "scripts": { | ||
"clean": "rm -rf dist", | ||
"build": "npm run clean && tsc", | ||
"test": "jest --config test/jest-config.json" | ||
"build": "npm run clean && tsc && npm run build:esm", | ||
"build:esm": "sed 's/module.exports =/export default/' dist/index.js > dist/index.mjs", | ||
"test": "ts-node test.ts" | ||
}, | ||
"devDependencies": { | ||
"@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" | ||
"@typescript-eslint/eslint-plugin": "^7.7.1", | ||
"@typescript-eslint/parser": "^7.7.1", | ||
"eslint": "^8.44.0", | ||
"prettier": "^3.2.5", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.4.5" | ||
} | ||
} |
# Content Security Policy builder | ||
[![Build Status](https://travis-ci.org/helmetjs/content-security-policy-builder.svg?branch=master)](https://travis-ci.org/helmetjs/content-security-policy-builder) | ||
Take an object and turn it into a Content Security Policy string. | ||
@@ -6,0 +4,0 @@ |
Sorry, the diff of this file is not supported yet
5894
6
7
55
24