[PR #4724] [MERGED] fix: cURL header imports without trailing space #4911

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

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/4724
Author: @stelardn
Created: 2/5/2025
Status: Merged
Merged: 2/19/2025
Merged by: @jamesgeorge007

Base: nextHead: bugfix/curl-header-imports-without-space


📝 Commits (1)

  • 295757b fix(curl): accepts header k:v pairs with no space after colon

📊 Changes

2 files changed (+43 additions, -0 deletions)

View changed files

📝 packages/hoppscotch-common/src/helpers/curl/__tests__/curlparser.spec.js (+42 -0)
📝 packages/hoppscotch-common/src/helpers/curl/sub_helpers/headers.ts (+1 -0)

📄 Description

Closes #4707

This PR addresses the issue where cURL headers fail to import when the key-value pairs are separated by a single ":" (without a trailing space). The fix replaces the first occurrence of ":" (assumed to be the key-value separator) with ": " (colon + space), ensuring proper parsing while maintaining support for values that contain colons. This does not introduce any unwanted side effects, as the parser already includes a trim step to handle trailing spaces.

What's changed

  • Updated the header parser to replace the first occurrence of ":" with ": " to ensure correct splitting.
  • Added a test case to validate the fix.

Notes to reviewers

I tried other approaches such as using a regex or single ":" as the separator, but these required additional steps to deal with some other edge cases which turned out to add more complexity to the flow.


🔄 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/4724 **Author:** [@stelardn](https://github.com/stelardn) **Created:** 2/5/2025 **Status:** ✅ Merged **Merged:** 2/19/2025 **Merged by:** [@jamesgeorge007](https://github.com/jamesgeorge007) **Base:** `next` ← **Head:** `bugfix/curl-header-imports-without-space` --- ### 📝 Commits (1) - [`295757b`](https://github.com/hoppscotch/hoppscotch/commit/295757b85db52a88d1fa1852bcf0c94d0798098f) fix(curl): accepts header k:v pairs with no space after colon ### 📊 Changes **2 files changed** (+43 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-common/src/helpers/curl/__tests__/curlparser.spec.js` (+42 -0) 📝 `packages/hoppscotch-common/src/helpers/curl/sub_helpers/headers.ts` (+1 -0) </details> ### 📄 Description Closes #4707 <!-- Issue # here --> <!-- Add an introduction into what this PR tries to solve in a couple of sentences --> This PR addresses the issue where cURL headers fail to import when the key-value pairs are separated by a single `":"` (without a trailing space). The fix replaces the first occurrence of `":"` (assumed to be the key-value separator) with `": "` (colon + space), ensuring proper parsing while maintaining support for values that contain colons. This does not introduce any unwanted side effects, as the parser already includes a trim step to handle trailing spaces. ### What's changed - Updated the header parser to replace the first occurrence of `":"` with `": "` to ensure correct splitting. - Added a test case to validate the fix. <!-- You can also choose to add a list of changes and if they have been completed or not by using the markdown to-do list syntax - [ ] Not Completed - [x] Completed --> ### Notes to reviewers <!-- Any information you feel the reviewer should know about when reviewing your PR --> I tried other approaches such as using a regex or single `":"` as the separator, but these required additional steps to deal with some other edge cases which turned out to add more complexity to the flow. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:24:24 +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#4911
No description provided.