mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 01:06:00 +03:00
[PR #4792] [MERGED] fix: preserve encoded characters in cURL URLs #4934
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#4934
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/4792
Author: @xTudoS
Created: 2/27/2025
Status: ✅ Merged
Merged: 7/24/2025
Merged by: @jamesgeorge007
Base:
next← Head:fix/allow-encoded-slash📝 Commits (3)
8335889Remove decodeURIComponent allowing encoded charsa626662chore: check environment present in curl866c7d5chore: cleanup📊 Changes
1 file changed (+23 additions, -1 deletions)
View changed files
📝
packages/hoppscotch-common/src/helpers/curl/curlparser.ts(+23 -1)📄 Description
Closes https://github.com/hoppscotch/hoppscotch/issues/4769
Some APIs may use encoded chars in their endpoints, if I'm importing a command, it is expected that it remains the same without any changes in the request scope.
When importing a cURL request into Hoppscotch, encoded characters like
%2Fwere being decoded to/, altering the intended URL structure. This caused issues with APIs that require specific encoded characters in their endpoints.For instance:
Fix
Introduced logic to check if the URL contains environment variables using a regex pattern
<<variable_name>>.If environment variables are present, we apply decodeURIComponent carefully to avoid decoding those placeholders.
If no environment variables are present, encoded characters are preserved in the URL as-is.
What’s Changed:
Replaced unconditional decoding with a conditional strategy that preserves encoded characters unless decoding is explicitly safe.
Introduced a helper
containsEnvVariables()and supporting regex for environment variable detection.Notes to reviewers
This PR do not fix the code generation because code generation is another repository
For code generation fix, I have open this PR https://github.com/hoppscotch/httpsnippet/pull/4
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.