mirror of
https://github.com/usebruno/bruno.git
synced 2025-06-20 11:48:03 +02:00
* fixed * refactor: conditionals. * refactor: Update importPostmanV2CollectionItem function to handle file and text formdata
This commit is contained in:
parent
9588b442f7
commit
3db7d54aca
@ -180,12 +180,27 @@ const importPostmanV2CollectionItem = (brunoParent, item, parentAuth, options) =
|
|||||||
if (bodyMode) {
|
if (bodyMode) {
|
||||||
if (bodyMode === 'formdata') {
|
if (bodyMode === 'formdata') {
|
||||||
brunoRequestItem.request.body.mode = 'multipartForm';
|
brunoRequestItem.request.body.mode = 'multipartForm';
|
||||||
|
|
||||||
each(i.request.body.formdata, (param) => {
|
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({
|
brunoRequestItem.request.body.multipartForm.push({
|
||||||
uid: uuid(),
|
uid: uuid(),
|
||||||
type: 'text',
|
type: type,
|
||||||
name: param.key,
|
name: param.key,
|
||||||
value: param.value,
|
value: value,
|
||||||
description: param.description,
|
description: param.description,
|
||||||
enabled: !param.disabled
|
enabled: !param.disabled
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user