feat(cli): refactor formUrlEncoded handling to use buildFormUrlEncodedPayload function

This commit is contained in:
Pragadesh-45
2025-06-23 18:49:29 +05:45
parent 04d0439c9d
commit cf5f52b7b9
3 changed files with 31 additions and 8 deletions

View File

@@ -329,11 +329,14 @@ const runSingleRequest = async function (
}
// stringify the request url encoded params
if (request.headers['content-type'] === 'application/x-www-form-urlencoded') {
const contentTypeHeader = Object.keys(request.headers).find(
name => name.toLowerCase() === 'content-type'
);
if (contentTypeHeader && request.headers[contentTypeHeader] === 'application/x-www-form-urlencoded') {
request.data = qs.stringify(request.data, { arrayFormat: "repeat" });
}
if (request?.headers?.['content-type'] === 'multipart/form-data') {
if (contentTypeHeader && request.headers[contentTypeHeader] === 'multipart/form-data') {
if (!(request?.data instanceof FormData)) {
let form = createFormData(request.data, collectionPath);
request.data = form;