diff --git a/packages/bruno-cli/changelog.md b/packages/bruno-cli/changelog.md index 8a6c3ae1b..542d1bda4 100644 --- a/packages/bruno-cli/changelog.md +++ b/packages/bruno-cli/changelog.md @@ -1,5 +1,9 @@ # Changelog +## 0.10.1 + +- fix(#233) Fixed Issue related to content header parsing + ## 0.10.0 - Support for proxying requests through a proxy server diff --git a/packages/bruno-cli/package.json b/packages/bruno-cli/package.json index 236c3d1cb..91ce4a19c 100644 --- a/packages/bruno-cli/package.json +++ b/packages/bruno-cli/package.json @@ -1,6 +1,6 @@ { "name": "@usebruno/cli", - "version": "0.10.0", + "version": "0.10.1", "license": "MIT", "main": "src/index.js", "bin": { diff --git a/packages/bruno-cli/src/runner/interpolate-vars.js b/packages/bruno-cli/src/runner/interpolate-vars.js index fb0221505..f4072dbe5 100644 --- a/packages/bruno-cli/src/runner/interpolate-vars.js +++ b/packages/bruno-cli/src/runner/interpolate-vars.js @@ -1,6 +1,17 @@ const Handlebars = require('handlebars'); const { each, forOwn, cloneDeep } = require('lodash'); +const getContentType = (headers = {}) => { + let contentType = ''; + forOwn(headers, (value, key) => { + if (key && key.toLowerCase() === 'content-type') { + contentType = value; + } + }); + + return contentType; +}; + const interpolateEnvVars = (str, processEnvVars) => { if (!str || !str.length || typeof str !== 'string') { return str; @@ -55,7 +66,9 @@ const interpolateVars = (request, envVars = {}, collectionVariables = {}, proces request.headers[interpolate(key)] = interpolate(value); }); - if (request.headers['content-type'] === 'application/json') { + const contentType = getContentType(request.headers); + + if (contentType.includes('json')) { if (typeof request.data === 'object') { try { let parsed = JSON.stringify(request.data); @@ -69,7 +82,7 @@ const interpolateVars = (request, envVars = {}, collectionVariables = {}, proces request.data = interpolate(request.data); } } - } else if (request.headers['content-type'] === 'application/x-www-form-urlencoded') { + } else if (contentType === 'application/x-www-form-urlencoded') { if (typeof request.data === 'object') { try { let parsed = JSON.stringify(request.data);