feat(url): import url encode settings from postman and insomnia (#5102)

This commit is contained in:
maintainer-bruno
2025-07-15 14:40:46 +05:30
committed by GitHub
parent ecc6c1604c
commit 16736958c1
4 changed files with 36 additions and 3 deletions

View File

@@ -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)) {

View File

@@ -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) {

View File

@@ -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",

View File

@@ -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",