mirror of
https://github.com/usebruno/bruno.git
synced 2025-02-22 12:41:37 +01:00
add decomment step in a try catch block (#2485)
* add decomment step in a try catch block * request params validation - fix unit tests
This commit is contained in:
parent
929d2b5299
commit
b031e1f009
@ -76,10 +76,15 @@ const prepareRequest = (request, collectionRoot) => {
|
|||||||
if (!contentTypeDefined) {
|
if (!contentTypeDefined) {
|
||||||
axiosRequest.headers['content-type'] = 'application/json';
|
axiosRequest.headers['content-type'] = 'application/json';
|
||||||
}
|
}
|
||||||
const jsonBody = decomment(request.body.json);
|
let jsonBody;
|
||||||
|
try {
|
||||||
|
jsonBody = decomment(request?.body?.json);
|
||||||
|
} catch (error) {
|
||||||
|
jsonBody = request?.body?.json;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
axiosRequest.data = JSONbig.parse(jsonBody);
|
axiosRequest.data = JSONbig.parse(jsonBody);
|
||||||
} catch (ex) {
|
} catch (error) {
|
||||||
axiosRequest.data = jsonBody;
|
axiosRequest.data = jsonBody;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,11 +172,16 @@ const prepareRequest = (request, collectionRoot, collectionPath) => {
|
|||||||
if (!contentTypeDefined) {
|
if (!contentTypeDefined) {
|
||||||
axiosRequest.headers['content-type'] = 'application/json';
|
axiosRequest.headers['content-type'] = 'application/json';
|
||||||
}
|
}
|
||||||
const body = decomment(request.body.json);
|
let jsonBody;
|
||||||
try {
|
try {
|
||||||
axiosRequest.data = JSONbig.parse(body);
|
jsonBody = decomment(request?.body?.json);
|
||||||
} catch (ex) {
|
} catch (error) {
|
||||||
axiosRequest.data = body;
|
jsonBody = request?.body?.json;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
axiosRequest.data = JSONbig.parse(jsonBody);
|
||||||
|
} catch (error) {
|
||||||
|
axiosRequest.data = jsonBody;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user