fix : invalid query string when duplicate query param keys are provided#5
Merged
nivedin merged 2 commits intohoppscotch:masterfrom Jul 9, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes invalid cURL snippets when requests include duplicate query parameters by replacing the old stringifier with a helper that leverages URLSearchParams.
- Introduce
getQueryStringhelper to correctly handle multiple values for the same key. - Swap out
queryStringifyforgetQueryStringin the main snippet generator. - Add new tests to verify behavior of duplicate query keys and empty queries.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/httpsnippet.ts | Replaced custom query serializer with getQueryString call |
| src/helpers/query-params.ts | Added helper that flattens query object into a proper querystring |
| src/httpsnippet.test.ts | Added tests for duplicate query params, array-indexed keys, and empty queries |
Comments suppressed due to low confidence (1)
src/helpers/query-params.ts:6
- The JSDoc should note that this function returns the raw query string without the leading
?so callers know they must prefix it when building full URLs.
export const getQueryString = (queryObj: ReducedHelperObject): string => {
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a fix to the issue https://github.com/hoppscotch/hoppscotch/issues/5001 in Hoppscotch, where the curl generated is invalid whenever there are duplicate query params.