@vulkano/core 1.8.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -272,14 +272,35 @@ module.exports = function loadServer() {
272
272
  rules: cspRules
273
273
  } = expressConfig.csp || {};
274
274
 
275
- if (cspEnabled) {
275
+ if (cspEnabled && cspRules) {
276
+
277
+ const cspRulesHeader = [];
278
+
279
+ if (Array.isArray(cspRules) && cspRules.length > 0) {
280
+
281
+ for ( let i = 0; i < cspRules.length; i += 1) {
282
+ cspRulesHeader.push(cspRules[i]);
283
+ }
284
+
285
+ } else if (typeof cspRules === 'object') {
286
+
287
+ Object.keys(cspRules).forEach( (r) => {
288
+ const tmpValues = cspRules[r];
289
+ if (Array.isArray(tmpValues)) {
290
+ cspRulesHeader.push(`${r} ${tmpValues.join(' ')}`);
291
+ } else if (typeof tmpValues === 'string') {
292
+ cspRulesHeader.push(`${r} ${tmpValues}`);
293
+ }
294
+ });
295
+
296
+ } else if (typeof cspRules === 'string') {
297
+
298
+ cspRulesHeader.push(cspRules);
276
299
 
277
- if (!Array.isArray(cspRules)) {
278
- console.error('Vulkano Error: ', 'The Content Security Policy Rules must be an array');
279
- return;
280
300
  }
281
301
 
282
- if (cspRules.length > 0) {
302
+ // Has Rules
303
+ if (cspRulesHeader.length > 0) {
283
304
 
284
305
  vulkano.use( (req, res, next) => {
285
306
 
@@ -287,7 +308,7 @@ module.exports = function loadServer() {
287
308
  res.setHeader('Report-To', JSON.stringify(cspReportTo));
288
309
  }
289
310
 
290
- res.setHeader('Content-Security-Policy', cspRules.join('; '));
311
+ res.setHeader('Content-Security-Policy', cspRulesHeader.join('; '));
291
312
 
292
313
  next();
293
314
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vulkano/core",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "A MVC framework using Express 4",
5
5
  "license": "MIT",
6
6
  "author": "Vulkano Team",