Skip to content

Commit 124c606

Browse files
authored
Merge pull request #14 from ericclemmons/14-startsWith
TypeError: headers.content-type.startsWith is not a function
2 parents ecd2c12 + 5ef2e7c commit 124c606

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/Recorder.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,7 @@ export class Recorder {
414414
});
415415

416416
// Because we JSON.parse responses, we need to stringify it
417-
if (
418-
headers["content-type"] &&
419-
headers["content-type"].startsWith("application/json")
420-
) {
417+
if (String(headers["content-type"]).includes("application/json")) {
421418
request.write(JSON.stringify(body));
422419
} else {
423420
request.write(body);
@@ -461,10 +458,7 @@ export class Recorder {
461458
const body = Buffer.concat(chunks).toString("utf8");
462459

463460
// Simple services oftent send "application/json; charset=utf-8"
464-
if (
465-
headers["content-type"] &&
466-
headers["content-type"].startsWith("application/json")
467-
) {
461+
if (String(headers["content-type"]).includes("application/json")) {
468462
try {
469463
return resolve(JSON.parse(body));
470464
} catch (error) {

0 commit comments

Comments
 (0)