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:
Anoop M D 2023-11-22 22:30:36 +05:30 committed by GitHub
commit 2ec343a95b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,16 +55,27 @@ const convertV21Auth = (array) => {
const importPostmanV2CollectionItem = (brunoParent, item, parentAuth) => {
brunoParent.items = brunoParent.items || [];
const folderMap = {};
each(item, (i) => {
if (isItemAFolder(i)) {
const baseFolderName = i.name;
let folderName = baseFolderName;
let count = 1;
while (folderMap[folderName]) {
folderName = `${baseFolderName}_${count}`;
count++;
}
const brunoFolderItem = {
uid: uuid(),
name: i.name,
name: folderName,
type: 'folder',
items: []
};
brunoParent.items.push(brunoFolderItem);
folderMap[folderName] = brunoFolderItem;
if (i.item && i.item.length) {
importPostmanV2CollectionItem(brunoFolderItem, i.item, i.auth ?? parentAuth);
}