[PR #4944] [CLOSED] fix: 4672 whitespace vars codesnippet generation #4999

Closed
opened 2026-03-17 02:29:12 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/4944
Author: @yousefmarey12
Created: 3/27/2025
Status: Closed

Base: mainHead: 4672-whitespace-vars-codesnippet-generation


📝 Commits (4)

  • 92e7e38 fix(EffectiveURL.ts): used regular expressions to resolve environment variables
  • 4df956d fix(EffectiveURL.ts): used regular expressions to resolve environment variables
  • e05996f Merge branch 'main' into 4672-whitespace-vars-codesnippet-generation
  • 3c41530 Merge branch 'main' into 4672-whitespace-vars-codesnippet-generation

📊 Changes

1 file changed (+80 additions, -20 deletions)

View changed files

📝 packages/hoppscotch-common/src/helpers/utils/EffectiveURL.ts (+80 -20)

📄 Description

Fix: #4672

The issue stated that the problem was with whitespace in the values of environment variables caused the code snippet generation not to work. Using whitespace in environment variable values as query parameters did not work. The request endpoint ended up not escaping strings, so the endpoint was literally http://example.com/query=<<variable>>. The problem wasn't really with whitespace as it was with dealing with environment variables in the url and parameters.

What's changed

I changed 2 aspects: changing the literal endpoint and modifying how params are computed. For params, it checks if there even is SOMETHING=<<VALUE>> and replaces the variable with its value. For the endpoint, it just replaces <<VARIABLE>> with its value without the << >>.

Notes to reviewers

What's of my concern is that I had to make sourceEnv an empty string, in which it is never an empty string (you can't have a variable in an empty string folder). There is also the source: auth and this PR has nothing to do with authentication, but I had to put it as it was a constant.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/4944 **Author:** [@yousefmarey12](https://github.com/yousefmarey12) **Created:** 3/27/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `4672-whitespace-vars-codesnippet-generation` --- ### 📝 Commits (4) - [`92e7e38`](https://github.com/hoppscotch/hoppscotch/commit/92e7e38b3b09ac23afed824ffeee8e9b8d701add) fix(EffectiveURL.ts): used regular expressions to resolve environment variables - [`4df956d`](https://github.com/hoppscotch/hoppscotch/commit/4df956dd16b10213f1d11c8b42ba88fa4181d727) fix(EffectiveURL.ts): used regular expressions to resolve environment variables - [`e05996f`](https://github.com/hoppscotch/hoppscotch/commit/e05996f5bba01ec5245511cb2d9728eb94afb4e2) Merge branch 'main' into 4672-whitespace-vars-codesnippet-generation - [`3c41530`](https://github.com/hoppscotch/hoppscotch/commit/3c41530d0cf869790fc1ae31f8e5b268847fe42c) Merge branch 'main' into 4672-whitespace-vars-codesnippet-generation ### 📊 Changes **1 file changed** (+80 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-common/src/helpers/utils/EffectiveURL.ts` (+80 -20) </details> ### 📄 Description Fix: #4672 The issue stated that the problem was with whitespace in the values of environment variables caused the code snippet generation not to work. Using whitespace in environment variable values as query parameters did not work. The request endpoint ended up not escaping strings, so the endpoint was literally `http://example.com/query=<<variable>>`. The problem wasn't really with whitespace as it was with dealing with environment variables in the url and parameters. ### What's changed I changed 2 aspects: changing the literal endpoint and modifying how params are computed. For params, it checks if there even is `SOMETHING=<<VALUE>>` and replaces the variable with its value. For the endpoint, it just replaces `<<VARIABLE>>` with its value without the `<< >>`. ### Notes to reviewers What's of my concern is that I had to make `sourceEnv` an empty string, in which it is never an empty string (you can't have a variable in an empty string folder). There is also the `source: auth` and this PR has nothing to do with authentication, but I had to put it as it was a constant. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:29:12 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#4999
No description provided.