mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-14 11:21:30 +00:00
fix: add missing URL helper translations for Bruno to Postman export (#7026)
* fix: add missing URL helper translations for Bruno to Postman export * fix : comment
This commit is contained in:
@@ -62,6 +62,11 @@ const simpleTranslations = {
|
||||
'req.getHeader': 'pm.request.headers.get',
|
||||
'req.setHeader': 'pm.request.headers.set',
|
||||
|
||||
// URL helper methods
|
||||
'req.getHost': 'pm.request.url.getHost',
|
||||
'req.getPath': 'pm.request.url.getPath',
|
||||
'req.getQueryString': 'pm.request.url.getQueryString',
|
||||
|
||||
// Response helpers
|
||||
// Note: res.getStatus(), res.getResponseTime(), res.getHeaders(), res.getUrl() are handled
|
||||
// in complexTransformations because they're function -> property conversions
|
||||
@@ -202,6 +207,11 @@ const complexTransformations = [
|
||||
pattern: 'req.getAuthMode',
|
||||
transform: () => buildMemberExpressionFromString('pm.request.auth.type')
|
||||
},
|
||||
// req.getPathParams() -> pm.request.url.variables
|
||||
{
|
||||
pattern: 'req.getPathParams',
|
||||
transform: () => buildMemberExpressionFromString('pm.request.url.variables')
|
||||
},
|
||||
|
||||
// Response helpers: function -> property conversions
|
||||
// res.getStatus() -> pm.response.code
|
||||
|
||||
@@ -178,4 +178,29 @@ console.log("Headers:", JSON.stringify(pm.request.headers));
|
||||
const translatedCode = translateBruToPostman(code);
|
||||
expect(translatedCode).toBe('const body = {id: 1}; pm.request.body.update({\n mode: "raw",\n raw: JSON.stringify(body)\n});');
|
||||
});
|
||||
|
||||
// URL helper methods tests
|
||||
it('should translate req.getHost() to pm.request.url.getHost()', () => {
|
||||
const code = 'const host = req.getHost();';
|
||||
const translatedCode = translateBruToPostman(code);
|
||||
expect(translatedCode).toBe('const host = pm.request.url.getHost();');
|
||||
});
|
||||
|
||||
it('should translate req.getPath() to pm.request.url.getPath()', () => {
|
||||
const code = 'const path = req.getPath();';
|
||||
const translatedCode = translateBruToPostman(code);
|
||||
expect(translatedCode).toBe('const path = pm.request.url.getPath();');
|
||||
});
|
||||
|
||||
it('should translate req.getQueryString() to pm.request.url.getQueryString()', () => {
|
||||
const code = 'const queryString = req.getQueryString();';
|
||||
const translatedCode = translateBruToPostman(code);
|
||||
expect(translatedCode).toBe('const queryString = pm.request.url.getQueryString();');
|
||||
});
|
||||
|
||||
it('should translate req.getPathParams() to pm.request.url.variables (function to property)', () => {
|
||||
const code = 'const pathParams = req.getPathParams();';
|
||||
const translatedCode = translateBruToPostman(code);
|
||||
expect(translatedCode).toBe('const pathParams = pm.request.url.variables;');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user