Skip to content

Commit

Permalink
fix: only encode body as JSON for content-type application/json
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathias Loesch committed Oct 10, 2017
1 parent e193550 commit fa035d2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}

Expand Down

0 comments on commit fa035d2

Please sign in to comment.