Skip to content

"&" encodes to %26 when generating code. This fixes the issue and whe… - #4

Open
Rohan-Bruno wants to merge 1 commit into
mainfrom
fix/encodingBetter
Open

"&" encodes to %26 when generating code. This fixes the issue and whe…#4
Rohan-Bruno wants to merge 1 commit into
mainfrom
fix/encodingBetter

Conversation

@Rohan-Bruno

@Rohan-Bruno Rohan-Bruno commented Aug 27, 2026

Copy link
Copy Markdown
Owner

…n URL Encoding is turned off & encodes as it is.

Description

Problem

Fix

Screenshots

Before After

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.
  • I've run the claude code review skill locally.

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

    • Fixed generated code URLs so ampersands within query parameter values are preserved correctly.
    • Ensured query values are properly percent-encoded when URL encoding is enabled.
    • Improved handling of authentication-generated query parameters to prevent incorrect parsing or double encoding.
  • Tests

    • Added regression coverage for encoded and unencoded ampersands in query values.

…n URL Encoding is turned off & encodes as it is.
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

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 Plus

Run ID: fa0c4862-056b-46bd-b225-b636cadaf1bd

📥 Commits

Reviewing files that changed from the base of the PR and between 7009c85 and 29de26e.

📒 Files selected for processing (5)
  • packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.js
  • packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js
  • packages/bruno-common/src/generate-code/har/index.ts
  • packages/bruno-common/src/utils/url/index.spec.ts
  • packages/bruno-common/src/utils/url/index.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


Walkthrough

The change preserves structured query parameters during URL encoding, HAR generation, and snippet rendering. It adds EncodeUrlOptions, updates buildHar, and adds regression tests for ampersands in query values.

Changes

Query Parameter Encoding

Layer / File(s) Summary
Structured URL encoding contract
packages/bruno-common/src/utils/url/index.ts, packages/bruno-common/src/utils/url/index.spec.ts
encodeUrl accepts structured query parameters and rebuilds queries through buildQueryString. Tests cover encoded and unencoded ampersands.
Canonical HAR query flow
packages/bruno-common/src/generate-code/har/index.ts
buildHar builds the query parameter array before URL encoding, preserves authentication query parameters, and stores the encoded URL without its query.
Snippet query rendering
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.js, packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js
The snippet URL anchor uses har.queryString directly. Tests cover literal ampersands in query values.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 29de2

This localized encoding fix is merge-ready after normal checks and review; no actionable merge-blocking risk remains.

Suggested reviewers: pooja-bruno, shubh-bruno

Poem

Query values keep their shape,
Ampersands no longer escape the map,
HAR paths stay clear,
Snippets render true,
Encoding guards the gap.

🚥 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 clearly describes the main change: correct encoding of ampersands as %26 during code generation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 5 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/encodingBetter

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant