From fa035d22fb04eb5df1fd539060c4e221fc984486 Mon Sep 17 00:00:00 2001 From: Mathias Loesch Date: Tue, 10 Oct 2017 15:34:38 +0200 Subject: [PATCH] fix: only encode body as JSON for content-type application/json --- src/util.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util.ts b/src/util.ts index fbf4e9b..7e50278 100644 --- a/src/util.ts +++ b/src/util.ts @@ -89,13 +89,13 @@ export function method(method: number) { } // Body - var urlencoded = headers.get('Content-Type'); + var contentType = headers.get('Content-Type'); var body = null; if (pBody) { - if (urlencoded && urlencoded === 'application/x-www-form-urlencoded') { - body = args[pBody[0].parameterIndex]; - } else { + if (contentType && contentType === 'application/json') { body = JSON.stringify(args[pBody[0].parameterIndex]); + } else { + body = args[pBody[0].parameterIndex]; } }