From adaa03b56bf17df2a9a69eb471e84460e0d1ad12 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Fri, 29 Apr 2022 20:45:47 +0200 Subject: [PATCH] fix: generalise `application/json` content types (#75) --- src/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 59cfdee..171045d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -28,7 +28,7 @@ const textTypes = new Set([ 'application/html' ]) -const jsonTypes = new Set(['application/json', 'application/ld+json']) +const JSON_RE = /^application\/(?:[\w!#$%&*`\-.^~]*\+)?json(;.+)?$/i interface ResponseMap { blob: Blob @@ -48,7 +48,7 @@ export function detectResponseType (_contentType = ''): ResponseType { // Value might look like: `application/json; charset=utf-8` const contentType = _contentType.split(';').shift()! - if (jsonTypes.has(contentType)) { + if (JSON_RE.test(contentType)) { return 'json' }