Skip to content

bugfix: export to postman when protocol and hostname is variable#8288

Open
GiteshDohare wants to merge 1 commit into
usebruno:mainfrom
GiteshDohare:bugfix/postman-export-variable-hostname
Open

bugfix: export to postman when protocol and hostname is variable#8288
GiteshDohare wants to merge 1 commit into
usebruno:mainfrom
GiteshDohare:bugfix/postman-export-variable-hostname

Conversation

@GiteshDohare

@GiteshDohare GiteshDohare commented Jun 17, 2026

Copy link
Copy Markdown

Description

Fixes: #8287

This PR fixes an issue where exporting a Bruno collection to a Postman collection formats an invalid path array if the request URL utilizes an environment/collection variable as the host (e.g., {{baseUrl}}) without a leading http:// or https:// protocol.

Updated transformUrl to cleanly isolate and strip out the query string via url.split('?') at the very top level before any path or protocol segmentation takes place.

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • 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.

Summary by CodeRabbit

  • Bug Fixes

    • Improved URL conversion to correctly separate query parameters from the path, ensuring proper formatting when converting to Postman format.
  • Tests

    • Added test case for URL conversion with environment variables and query parameters.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 217f33d9-81e3-4316-912f-7425a7f298ec

📥 Commits

Reviewing files that changed from the base of the PR and between ba063f6 and 38435b8.

📒 Files selected for processing (2)
  • packages/bruno-converters/src/postman/bruno-to-postman.js
  • packages/bruno-converters/tests/postman/bruno-to-postman.spec.js

Walkthrough

transformUrl in bruno-to-postman.js is updated to strip the query string from the URL before passing it into the splitUrl pipeline, preventing query parameters from leaking into the path array. The splitUrl internal branch is simplified accordingly. A new test covers env-variable base URLs with path and query parameters.

Changes

Bruno-to-Postman URL Conversion Fix

Layer / File(s) Summary
Query-string stripping in transformUrl / splitUrl
packages/bruno-converters/src/postman/bruno-to-postman.js
Derives urlWithoutQuery by splitting on ? before protocol/host/path parsing; removes the redundant query-extraction inside the urlParts.length === 2 branch; passes urlWithoutQuery into splitUrl instead of the raw url.
Test: env-variable base URL with query params
packages/bruno-converters/tests/postman/bruno-to-postman.spec.js
Adds a transformUrl test asserting that {{baseUrl}}/{{username}}/:id?foo=bar&baz=qux correctly places query params in query and keeps path segments clean.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

size/S

Suggested reviewers

  • helloanoop
  • bijin-bruno
  • lohit-bruno
  • naman-bruno

Poem

A query once snuck into the path array's lair,
Appending ?foo=bar with a devious flair 🐛
But now a trim slash splits the string in two,
urlWithoutQuery keeps the path clean and true ✨
The test stands guard — no leakage shall pass through!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the core bug fix: preventing query parameters from being incorrectly appended to the path array when protocol and hostname are variables.
Linked Issues check ✅ Passed The code changes directly address issue #8287 by isolating query strings before path/protocol parsing, ensuring query parameters are properly separated from path segments in Postman exports.
Out of Scope Changes check ✅ Passed All changes are scoped to the transformUrl function and its test case, directly addressing the query string handling issue without introducing unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Exporting collection to Postman appends query parameters to the path array when using a base URL variable

1 participant