mirror of
https://github.com/usebruno/bruno.git
synced 2025-06-20 11:48:03 +02:00
Merge pull request #993 from Jofresh/feature/handle-import-postman-folder-same-name
feat: handle postman import with same folder names (#955)
This commit is contained in:
commit
2ec343a95b
@ -55,16 +55,27 @@ const convertV21Auth = (array) => {
|
|||||||
|
|
||||||
const importPostmanV2CollectionItem = (brunoParent, item, parentAuth) => {
|
const importPostmanV2CollectionItem = (brunoParent, item, parentAuth) => {
|
||||||
brunoParent.items = brunoParent.items || [];
|
brunoParent.items = brunoParent.items || [];
|
||||||
|
const folderMap = {};
|
||||||
|
|
||||||
each(item, (i) => {
|
each(item, (i) => {
|
||||||
if (isItemAFolder(i)) {
|
if (isItemAFolder(i)) {
|
||||||
|
const baseFolderName = i.name;
|
||||||
|
let folderName = baseFolderName;
|
||||||
|
let count = 1;
|
||||||
|
|
||||||
|
while (folderMap[folderName]) {
|
||||||
|
folderName = `${baseFolderName}_${count}`;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
const brunoFolderItem = {
|
const brunoFolderItem = {
|
||||||
uid: uuid(),
|
uid: uuid(),
|
||||||
name: i.name,
|
name: folderName,
|
||||||
type: 'folder',
|
type: 'folder',
|
||||||
items: []
|
items: []
|
||||||
};
|
};
|
||||||
brunoParent.items.push(brunoFolderItem);
|
brunoParent.items.push(brunoFolderItem);
|
||||||
|
folderMap[folderName] = brunoFolderItem;
|
||||||
if (i.item && i.item.length) {
|
if (i.item && i.item.length) {
|
||||||
importPostmanV2CollectionItem(brunoFolderItem, i.item, i.auth ?? parentAuth);
|
importPostmanV2CollectionItem(brunoFolderItem, i.item, i.auth ?? parentAuth);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user