Skip to content

Commit acb53ef

Browse files
committed
Fix charset encoding header
1 parent 924db75 commit acb53ef

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/router.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ router.applyMiddleware = () => {
5555
if (req.headers.accept) {
5656
// 406 Not Acceptable
5757
let matchingTypes = req.headers.accept.split(/, ?/)
58-
matchingTypes = matchingTypes.filter(mediaType => // Accept application/*, */vnd.api+json, */* and the correct JSON:API type.
59-
mediaType.match(/^(\*|application)\/(\*|json|vnd\.api\+json)$/) || mediaType.match(/\*\/\*/))
58+
matchingTypes = matchingTypes.filter(mediaType => {
59+
// Remove charset encoding
60+
const type = mediaType.split(';')[0];
61+
// Accept application/*, */vnd.api+json, */* and the correct JSON:API type.
62+
return type.match(/^(\*|application)\/(\*|json|vnd\.api\+json)$/) || type.match(/\*\/\*/)
63+
})
6064

6165
if (matchingTypes.length === 0) {
6266
return res.status(406).end()

0 commit comments

Comments
 (0)