mirror of
https://github.com/usebruno/bruno.git
synced 2025-06-21 04:08:01 +02:00
fix(#233): bru cli fix for content header parsing issue
This commit is contained in:
parent
5d01c0a765
commit
0517b2685e
@ -1,5 +1,9 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.10.1
|
||||||
|
|
||||||
|
- fix(#233) Fixed Issue related to content header parsing
|
||||||
|
|
||||||
## 0.10.0
|
## 0.10.0
|
||||||
|
|
||||||
- Support for proxying requests through a proxy server
|
- Support for proxying requests through a proxy server
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@usebruno/cli",
|
"name": "@usebruno/cli",
|
||||||
"version": "0.10.0",
|
"version": "0.10.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
@ -1,6 +1,17 @@
|
|||||||
const Handlebars = require('handlebars');
|
const Handlebars = require('handlebars');
|
||||||
const { each, forOwn, cloneDeep } = require('lodash');
|
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) => {
|
const interpolateEnvVars = (str, processEnvVars) => {
|
||||||
if (!str || !str.length || typeof str !== 'string') {
|
if (!str || !str.length || typeof str !== 'string') {
|
||||||
return str;
|
return str;
|
||||||
@ -55,7 +66,9 @@ const interpolateVars = (request, envVars = {}, collectionVariables = {}, proces
|
|||||||
request.headers[interpolate(key)] = interpolate(value);
|
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') {
|
if (typeof request.data === 'object') {
|
||||||
try {
|
try {
|
||||||
let parsed = JSON.stringify(request.data);
|
let parsed = JSON.stringify(request.data);
|
||||||
@ -69,7 +82,7 @@ const interpolateVars = (request, envVars = {}, collectionVariables = {}, proces
|
|||||||
request.data = interpolate(request.data);
|
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') {
|
if (typeof request.data === 'object') {
|
||||||
try {
|
try {
|
||||||
let parsed = JSON.stringify(request.data);
|
let parsed = JSON.stringify(request.data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user