mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-25 01:14:23 +01:00
Handling request name conflicts while importing postman V2 collections (#1298)
Issue: In Postman, multiple requests in same folder can have same name. current import code is creating bruneRequestItems with same name which is causing only one of the original requests to be actaully created. Looks like bruno doesn't allow multiple requests with same name in a given folder. Fix: Append _<duplicate_count> to conflicting request names within same folder.
This commit is contained in:
parent
0937bab7f5
commit
0d3fde5efd
@ -59,7 +59,8 @@ let translationLog = {};
|
|||||||
const importPostmanV2CollectionItem = (brunoParent, item, parentAuth, options) => {
|
const importPostmanV2CollectionItem = (brunoParent, item, parentAuth, options) => {
|
||||||
brunoParent.items = brunoParent.items || [];
|
brunoParent.items = brunoParent.items || [];
|
||||||
const folderMap = {};
|
const folderMap = {};
|
||||||
|
const requestMap = {};
|
||||||
|
|
||||||
each(item, (i) => {
|
each(item, (i) => {
|
||||||
if (isItemAFolder(i)) {
|
if (isItemAFolder(i)) {
|
||||||
const baseFolderName = i.name;
|
const baseFolderName = i.name;
|
||||||
@ -84,6 +85,15 @@ const importPostmanV2CollectionItem = (brunoParent, item, parentAuth, options) =
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (i.request) {
|
if (i.request) {
|
||||||
|
const baseRequestName = i.name;
|
||||||
|
let requestName = baseRequestName;
|
||||||
|
let count = 1;
|
||||||
|
|
||||||
|
while (requestMap[requestName]) {
|
||||||
|
requestName = `${baseRequestName}_${count}`;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
let url = '';
|
let url = '';
|
||||||
if (typeof i.request.url === 'string') {
|
if (typeof i.request.url === 'string') {
|
||||||
url = i.request.url;
|
url = i.request.url;
|
||||||
@ -93,7 +103,7 @@ const importPostmanV2CollectionItem = (brunoParent, item, parentAuth, options) =
|
|||||||
|
|
||||||
const brunoRequestItem = {
|
const brunoRequestItem = {
|
||||||
uid: uuid(),
|
uid: uuid(),
|
||||||
name: i.name,
|
name: requestName,
|
||||||
type: 'http-request',
|
type: 'http-request',
|
||||||
request: {
|
request: {
|
||||||
url: url,
|
url: url,
|
||||||
@ -308,6 +318,7 @@ const importPostmanV2CollectionItem = (brunoParent, item, parentAuth, options) =
|
|||||||
});
|
});
|
||||||
|
|
||||||
brunoParent.items.push(brunoRequestItem);
|
brunoParent.items.push(brunoRequestItem);
|
||||||
|
requestMap[requestName] = brunoRequestItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user