bruno icon indicating copy to clipboard operation
bruno copied to clipboard

feat: update URL API support to req.getUrl()

Open james-ha-bruno opened this issue 1 month ago • 0 comments

Description

Implement Postman URL API Compatibility and update Bruno's JS Method.

Enable seamless translation of Postman scripts to Bruno by implementing full compatibility with Postman's pm.request.url API in Bruno's req.getUrl() method.

What Changed

Enhanced req.getUrl() Method

The req.getUrl() method now returns a String object with additional properties and methods that match Postman's URL API:

// Before: req.getUrl() returned a plain string
const url = req.getUrl(); // "https://api.example.com/users/123"

// After: req.getUrl() returns a String object with properties
const url = req.getUrl();
url.host;        // ["api", "example", "com"] - array of hostname parts
url.path;        // ["users", "123"] - array of path segments
url.getHost();   // "api.example.com" - hostname as string
url.path[0];     // "users" - individual path segment

Postman script translation

Postman scripts are now automatically translated to Bruno:

// Postman
pm.request.url.getHost()
pm.request.url.path[0]
pm.request.url.host

// Translates to Bruno
req.getUrl().host.join('.')
req.getUrl().path[0]
req.getUrl().host

Images

image

Contribution Checklist:

  • [x] The pull request only addresses one issue or adds one feature.
  • [x] The pull request does not introduce any breaking changes
  • [x] I have added screenshots or gifs to help explain the change if applicable.
  • [x] I have read the contribution guidelines.
  • [x] Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

james-ha-bruno avatar Nov 11 '25 02:11 james-ha-bruno