fix: "URL encoding off" ignored for multi-param URLs in generated code#7769
fix: "URL encoding off" ignored for multi-param URLs in generated code#7769prateek-bruno wants to merge 2 commits intousebruno:mainfrom
Conversation
WalkthroughChanged query-string serialization in the snippet generator to call Changes
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js (1)
1253-1261: Strengthen this assertion to verify query param order explicitly.The test title says “non-alphabetical order”, but current checks can still pass if params are reordered. Assert the ordered encoded fragment directly.
Suggested test assertion update
it('should encode URL with multiple query params in non-alphabetical order when encodeUrl is true', () => { const rawUrl = 'https://example.com/api?start=2026-02-01T00:00:00.000Z&a=b'; const item = makeItem(rawUrl, { encodeUrl: true }); const result = generateSnippet({ language, item, collection: baseCollection, shouldInterpolate: false }); - expect(result).toContain('%3A'); - expect(result).toContain('start='); - expect(result).toContain('a=b'); + expect(result).toContain('start=2026-02-01T00%3A00%3A00.000Z&a=b'); });As per coding guidelines, “Write behaviour-driven tests, not implementation-driven ones” and “Aim for tests that fail usefully.”
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js` around lines 1253 - 1261, Update the test case that checks URL encoding order so it asserts the exact encoded query fragment in order instead of loosely checking pieces; specifically, in the "should encode URL with multiple query params in non-alphabetical order when encodeUrl is true" test (using makeItem, generateSnippet, language, baseCollection), replace the loose expect(result).toContain checks with a single assertion that the result contains the exact encoded fragment showing the timestamp encoded and then "&a=b" (preserving the original non-alphabetical param order), e.g. assert the encoded "start=..." segment immediately followed by "&a=b".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js`:
- Around line 1253-1261: Update the test case that checks URL encoding order so
it asserts the exact encoded query fragment in order instead of loosely checking
pieces; specifically, in the "should encode URL with multiple query params in
non-alphabetical order when encodeUrl is true" test (using makeItem,
generateSnippet, language, baseCollection), replace the loose
expect(result).toContain checks with a single assertion that the result contains
the exact encoded fragment showing the timestamp encoded and then "&a=b"
(preserving the original non-alphabetical param order), e.g. assert the encoded
"start=..." segment immediately followed by "&a=b".
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3fe9a35c-ba9d-4bb3-b814-3041254a78ff
📒 Files selected for processing (1)
packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/utils/snippet-generator.spec.js
Description
Fixes #7524
Root cause
In snippet-generator.js, we compute httpSnippetPath via query-string's stringify, then replaceAll it with the raw URL when encoding is off. stringify sorts keys alphabetically by default, so the predicted string (a=b&start=...) no longer matches HTTPSnippet's actual output (start=...&a=b), replaceAll silently no-ops and the encoded URL remains. With a single param there's nothing to sort, which is why the bug was masked.
Fix
One-line change: pass { sort: false } to stringify so param order is preserved.
After:

Before:

Contribution Checklist:
Summary by CodeRabbit
Bug Fixes
Tests