Skip to content

Commit

Permalink
fix(curly): use default content-type when there are no headers received
Browse files Browse the repository at this point in the history
  • Loading branch information
liamdiprose authored and JCMais committed Dec 3, 2024
1 parent 7a7c0a2 commit 3f40784
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/curly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,12 @@ const create = (defaultOptions: CurlyOptions = {}): CurlyFunction => {
return
}

const contentTypeEntry = Object.entries(
headers[headers.length - 1],
).find(([k]) => k.toLowerCase() === 'content-type')
const contentTypeEntry =
headers.length > 0
? Object.entries(headers[headers.length - 1]).find(
([k]) => k.toLowerCase() === 'content-type',
)
: null

let contentType = (
contentTypeEntry ? contentTypeEntry[1] : ''
Expand Down

0 comments on commit 3f40784

Please sign in to comment.