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:
lohit 2024-06-21 10:45:12 +05:30 committed by GitHub
parent 929d2b5299
commit b031e1f009
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 6 deletions

View File

@ -76,10 +76,15 @@ const prepareRequest = (request, collectionRoot) => {
if (!contentTypeDefined) {
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 {
axiosRequest.data = JSONbig.parse(jsonBody);
} catch (ex) {
} catch (error) {
axiosRequest.data = jsonBody;
}
}

View File

@ -172,11 +172,16 @@ const prepareRequest = (request, collectionRoot, collectionPath) => {
if (!contentTypeDefined) {
axiosRequest.headers['content-type'] = 'application/json';
}
const body = decomment(request.body.json);
let jsonBody;
try {
axiosRequest.data = JSONbig.parse(body);
} catch (ex) {
axiosRequest.data = body;
jsonBody = decomment(request?.body?.json);
} catch (error) {
jsonBody = request?.body?.json;
}
try {
axiosRequest.data = JSONbig.parse(jsonBody);
} catch (error) {
axiosRequest.data = jsonBody;
}
}