Skip to content

Conversation

@SharadSaha
Copy link

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.

@nivedin nivedin requested a review from Copilot July 9, 2025 12:54
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 getQueryString helper to correctly handle multiple values for the same key.
  • Swap out queryStringify for getQueryString in 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 => {

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.

2 participants