Comparing version 2.4.1 to 2.4.2
@@ -5,3 +5,2 @@ 'use strict'; | ||
const Hoek = require('hoek'); | ||
const Accepts = require('accepts'); | ||
@@ -49,2 +48,4 @@ | ||
// Check for header and route mapping and convert and reply with csv if needed | ||
const allowedTypesRegex = /(text\/csv)|(application\/csv)/i; | ||
server.ext('onPreResponse', (request, reply) => { | ||
@@ -61,8 +62,5 @@ | ||
const oldAcceptHeader = request.headers.accept; | ||
request.headers.accept = request.headers.accept.replace(/\*\/\*/g, ''); | ||
const result = allowedTypesRegex.exec(request.headers.accept); | ||
const preferedType = result && result[0]; | ||
const accept = Accepts(request); | ||
const preferedType = accept.types(['text/csv', 'application/csv']); | ||
if (preferedType && internals.routeMap.has(request.route.path)) { | ||
@@ -79,4 +77,2 @@ const schema = internals.routeMap.get(request.route.path); | ||
request.headers.accept = oldAcceptHeader; | ||
return reply.continue(); | ||
@@ -83,0 +79,0 @@ }); |
{ | ||
"name": "hapi-csv", | ||
"version": "2.4.1", | ||
"version": "2.4.2", | ||
"description": "Hapi plugin for converting a Joi response schema and dataset to csv", | ||
@@ -24,3 +24,2 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"accepts": "1.3.x", | ||
"hoek": "4.x.x" | ||
@@ -27,0 +26,0 @@ }, |
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
3
25947
536
+ Addedmime-db@1.53.0(transitive)
- Removedaccepts@1.3.x
- Removedaccepts@1.3.8(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removednegotiator@0.6.3(transitive)