hoppscotch: [bug]: query parameters are escaped implicitly

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

When I send a Get request with the following parameters(in bulk edit).

token: token_part1 token_part2
attrs: password%3Dabc

The actual request sent is url?token=token_part1+token_part2&attrs=password%253Dabc which is wrong for my server.

If I send the same Get request using postman, the actual request sent is url?token=token_part1%20token_part2&attrs=password%3Dabc which is correct for my server.

I found the problem code is around the following code.

https://github.com/hoppscotch/hoppscotch/blob/dc80cc80e6e9c02c41a0754dfa7868f7f102964a/packages/hoppscotch-app/src/helpers/strategies/ExtensionStrategy.ts#L64-L70

url=new URL("http://localhost")
url.searchParams.append('token','token_part1 token_part2')
url.searchParams.append('attrs','password%3Dabc')
console.info(url.toString()) // http://localhost/?token=token_part1+token_part2&attrs=password%253abc

url=new URL('http://localhost/?token=token_part1+token_part2&attrs=password%253abc')
console.info(url.searchParams.get('token')) // token_part1 token_part2
console.info(url.searchParams.get('attrs')) // password%3Dabc
console.info(decodeURI('http://localhost/?token=token_part1+token_part2&attrs=password%253abc')) // http://localhost/?token=token_part1+token_part2&attrs=password%3Dabc


See also https://developer.mozilla.org/en-US/docs/Web/API/URL/toString, https://javascript.info/url, https://url.spec.whatwg.org/#URL-stringification-behavior.

Steps to reproduce

  1. Go to Parameters tab, click Bulk edit.
  2. Fill with the following contents
token: token_part1 token_part2
attrs: password%3Dabc
  1. Click Send button to make the request.

Environment

Release

Version

Cloud

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 16 (4 by maintainers)

Most upvoted comments

Assigning to @maneeshms.