Skip to content

Commit

Permalink
fix: generalise application/json content types (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored and pi0 committed Apr 29, 2022
1 parent b7ae479 commit adaa03b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
}

Expand Down

0 comments on commit adaa03b

Please sign in to comment.