mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-15 11:51:30 +00:00
feat(url): import url encode settings from postman and insomnia (#5102)
This commit is contained in:
@@ -157,6 +157,12 @@ const transformInsomniaRequestItem = (request, index, allRequests) => {
|
||||
brunoRequestItem.request.body.graphql = parseGraphQL(request.body.text);
|
||||
}
|
||||
|
||||
const settings = {
|
||||
encodeUrl: request.settings?.encodeUrl !== false && request.settingEncodeUrl !== false, // handles v4 and v5 import
|
||||
}
|
||||
|
||||
brunoRequestItem.settings = settings;
|
||||
|
||||
return brunoRequestItem;
|
||||
};
|
||||
|
||||
@@ -200,7 +206,8 @@ const parseInsomniaV5Collection = (data) => {
|
||||
parameters: item.parameters || [],
|
||||
pathParameters: item.pathParameters || [],
|
||||
authentication: item.authentication || {},
|
||||
body: item.body || {}
|
||||
body: item.body || {},
|
||||
settings: item.settings || {}
|
||||
};
|
||||
return transformInsomniaRequestItem(request, index, allItems);
|
||||
} else if (item.children && Array.isArray(item.children)) {
|
||||
|
||||
@@ -380,6 +380,12 @@ const importPostmanV2CollectionItem = (brunoParent, item, parentAuth, { useWorke
|
||||
}
|
||||
};
|
||||
|
||||
const settings = {
|
||||
encodeUrl: i.protocolProfileBehavior?.disableUrlEncoding !== true
|
||||
}
|
||||
|
||||
brunoRequestItem.settings = settings;
|
||||
|
||||
brunoParent.items.push(brunoRequestItem);
|
||||
|
||||
if (i.event) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import insomniaToBruno from '../../src/insomnia/insomnia-to-bruno';
|
||||
describe('insomnia-collection', () => {
|
||||
it('should correctly import a valid Insomnia v5 collection file', async () => {
|
||||
const brunoCollection = insomniaToBruno(insomniaCollection);
|
||||
|
||||
|
||||
expect(brunoCollection).toMatchObject(expectedOutput)
|
||||
});
|
||||
});
|
||||
@@ -59,7 +59,7 @@ collection:
|
||||
method: GET
|
||||
settings:
|
||||
renderRequestBody: true
|
||||
encodeUrl: true
|
||||
encodeUrl: false
|
||||
followRedirects: global
|
||||
cookies:
|
||||
send: true
|
||||
@@ -113,6 +113,9 @@ const expectedOutput = {
|
||||
"seq": 1,
|
||||
"type": "http-request",
|
||||
"uid": "mockeduuidvalue123456",
|
||||
"settings": {
|
||||
"encodeUrl": true,
|
||||
},
|
||||
},
|
||||
],
|
||||
"name": "Folder1",
|
||||
@@ -146,6 +149,9 @@ const expectedOutput = {
|
||||
"seq": 1,
|
||||
"type": "http-request",
|
||||
"uid": "mockeduuidvalue123456",
|
||||
"settings": {
|
||||
"encodeUrl": false,
|
||||
},
|
||||
},
|
||||
],
|
||||
"name": "Folder2",
|
||||
|
||||
@@ -22,6 +22,7 @@ const insomniaCollection = {
|
||||
"name": "Request1",
|
||||
"method": "GET",
|
||||
"url": "https://httpbin.org/get",
|
||||
"settingEncodeUrl": false,
|
||||
"parameters": []
|
||||
},
|
||||
{
|
||||
@@ -31,6 +32,7 @@ const insomniaCollection = {
|
||||
"name": "Request2",
|
||||
"method": "GET",
|
||||
"url": "https://httpbin.org/get",
|
||||
"settingEncodeUrl": true,
|
||||
"parameters": []
|
||||
},
|
||||
{
|
||||
@@ -92,6 +94,9 @@ const expectedOutput = {
|
||||
"seq": 1,
|
||||
"type": "http-request",
|
||||
"uid": "mockeduuidvalue123456",
|
||||
"settings": {
|
||||
"encodeUrl": false,
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "Request1",
|
||||
@@ -118,6 +123,9 @@ const expectedOutput = {
|
||||
"seq": 2,
|
||||
"type": "http-request",
|
||||
"uid": "mockeduuidvalue123456",
|
||||
"settings": {
|
||||
"encodeUrl": false,
|
||||
},
|
||||
},
|
||||
],
|
||||
"name": "Folder1",
|
||||
@@ -151,6 +159,9 @@ const expectedOutput = {
|
||||
"seq": 1,
|
||||
"type": "http-request",
|
||||
"uid": "mockeduuidvalue123456",
|
||||
"settings": {
|
||||
"encodeUrl": true,
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "Request2",
|
||||
@@ -177,6 +188,9 @@ const expectedOutput = {
|
||||
"seq": 2,
|
||||
"type": "http-request",
|
||||
"uid": "mockeduuidvalue123456",
|
||||
"settings": {
|
||||
"encodeUrl": true,
|
||||
},
|
||||
},
|
||||
],
|
||||
"name": "Folder2",
|
||||
|
||||
Reference in New Issue
Block a user