* fixed

* refactor: conditionals.

* refactor: Update importPostmanV2CollectionItem function to handle file and text formdata
This commit is contained in:
Sanjai Kumar 2024-06-18 17:05:09 +05:30 committed by GitHub
parent 9588b442f7
commit 3db7d54aca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -180,12 +180,27 @@ const importPostmanV2CollectionItem = (brunoParent, item, parentAuth, options) =
if (bodyMode) {
if (bodyMode === 'formdata') {
brunoRequestItem.request.body.mode = 'multipartForm';
each(i.request.body.formdata, (param) => {
const isFile = param.type === 'file';
let value;
let type;
if (isFile) {
// If param.src is an array, keep it as it is.
// If param.src is a string, convert it into an array with a single element.
value = Array.isArray(param.src) ? param.src : typeof param.src === 'string' ? [param.src] : null;
type = 'file';
} else {
value = param.value;
type = 'text';
}
brunoRequestItem.request.body.multipartForm.push({
uid: uuid(),
type: 'text',
type: type,
name: param.key,
value: param.value,
value: value,
description: param.description,
enabled: !param.disabled
});