From 6ebcecae80d74a5249eca99418500b0016f0240c Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Wed, 10 Jun 2020 20:05:23 -0400 Subject: [PATCH] Added support for full content-type headers in isJSONContentType --- functions/utils/contenttypes.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/functions/utils/contenttypes.js b/functions/utils/contenttypes.js index 4e9173cee..d9f1d8177 100644 --- a/functions/utils/contenttypes.js +++ b/functions/utils/contenttypes.js @@ -9,9 +9,19 @@ export const knownContentTypes = [ ] export function isJSONContentType(contentType) { - return ( - contentType === "application/json" || - contentType === "application/vnd.api+json" || - contentType === "application/hal+json" - ) + if (contentType.includes(";")) { + const [justContentType] = contentType.split(";") + + return ( + justContentType === "application/json" || + justContentType === "application/vnd.api+json" || + justContentType === "application/hal+json" + ) + } else { + return ( + contentType === "application/json" || + contentType === "application/vnd.api+json" || + contentType === "application/hal+json" + ) + } }