[PR #5565] fix: [5559] handle URL parsing when --compressed flag directly precedes URL #5265

Open
opened 2026-03-17 02:43:39 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5565
Author: @ankur-2103
Created: 11/7/2025
Status: 🔄 Open

Base: mainHead: fix/5559-url-not-recognized-compressed-flag


📝 Commits (2)

  • 28efadb fix: handle URL parsing when --compressed flag directly precedes URL (#5559)
  • b28eb7c test: fix failing test case for --compressed flag parsing (#5559)

📊 Changes

1 file changed (+6 additions, -1 deletions)

View changed files

📝 packages/hoppscotch-common/src/helpers/curl/curlparser.ts (+6 -1)

📄 Description

🧩 Fix: cURL Parser URL Missing When Using --compressed

📋 Summary

This update fixes a bug in Hoppscotch where importing a cURL command containing the --compressed flag caused the request URL (endpoint) to be missing or incorrectly parsed.

When importing cURL commands such as:

curl -H 'Host: www.domai.name' \
-H 'Cookie: GUID=abc123zxcasdqwe' \
-H 'sec-fetch-user: ?1' \
-H 'sec-fetch-dest: document' \
-H 'sec-ch-ua-full-version-list: "(Not(A:Brand";v="99.0.0.0", "Google Chrome";v="134", "Chromium";v="134"' \
-H 'priority: u=0, i' \
--compressed 'https://www.domai.name/'

Fix Implemented

The issue occurred because yargs-parser treated the URL as a value for the --compressed flag.
To fix this, the parser configuration was updated to explicitly mark --compressed as a boolean flag, ensuring it doesn’t capture the next token (the URL).

Code Change

const args: parser.Arguments = parser(curlCommand, {
  boolean: ["compressed"],
  configuration: {
    "parse-numbers": false,
    "camel-case-expansion": false,
    "boolean-negation": false,
  },
})

⚙️ 2️⃣ Configuration Explanation

Show what each option does and why it matters.


⚙️ Configuration Explanation

Option Default Updated Description
boolean: ["compressed"] Added Ensures --compressed is a standalone flag, not consuming the next value (URL)
"parse-numbers": false true false Keeps all values as strings; avoids unintended type conversion
"camel-case-expansion": false true false Keeps flag names unchanged (e.g., --data-urlencode stays the same)
"boolean-negation": false true false Prevents negation of flags like --no-keepalive

🧪 Verification

Test Case 1 — Original Input

curl -H 'Host: www.domai.name' \
-H 'Cookie: GUID=abc123zxcasdqwe' \
-H 'sec-fetch-user: ?1' \
-H 'sec-fetch-dest: document' \
-H 'sec-ch-ua-full-version-list: "(Not(A:Brand";v="99.0.0.0", "Google Chrome";v="134", "Chromium";v="134"' \
-H 'priority: u=0, i' \
--compressed 'https://www.domai.name/'

Test Case 2 — POST Request with JSON Body and Cookies

curl -X POST 'https://api.example.com/v1/users' \
-H 'Host: api.example.com' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer abc123tokenxyz' \
-H 'User-Agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_0_0)"' \
-H 'accept-language: en-US,en;q=0.9' \
-H 'x-request-id: 98765' \
--cookie 'sessionid=xyz789; theme=dark' \
--compressed \
-d '{"name": "Ankur", "email": "ankur@example.com", "role": "frontend"}'

🧾 Change Type

Type Scope Impact
🐞 Bug Fix helpers/curl/curlparser.ts Fixes URL parsing issue for --compressed flag

👨‍💻 Author

@ankur-2103
Fixed boolean flag handling for --compressed in the cURL import parser.


🔄 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/5565 **Author:** [@ankur-2103](https://github.com/ankur-2103) **Created:** 11/7/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/5559-url-not-recognized-compressed-flag` --- ### 📝 Commits (2) - [`28efadb`](https://github.com/hoppscotch/hoppscotch/commit/28efadb4ab4f4419bca4b755302e7afaf0f3769f) fix: handle URL parsing when --compressed flag directly precedes URL (#5559) - [`b28eb7c`](https://github.com/hoppscotch/hoppscotch/commit/b28eb7cf3abff1eeba1c84a9b60ef9c4377ed5c9) test: fix failing test case for --compressed flag parsing (#5559) ### 📊 Changes **1 file changed** (+6 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-common/src/helpers/curl/curlparser.ts` (+6 -1) </details> ### 📄 Description # 🧩 Fix: cURL Parser URL Missing When Using `--compressed` ## 📋 Summary This update fixes a bug in Hoppscotch where importing a cURL command containing the `--compressed` flag caused the **request URL (endpoint)** to be missing or incorrectly parsed. When importing cURL commands such as: ```bash curl -H 'Host: www.domai.name' \ -H 'Cookie: GUID=abc123zxcasdqwe' \ -H 'sec-fetch-user: ?1' \ -H 'sec-fetch-dest: document' \ -H 'sec-ch-ua-full-version-list: "(Not(A:Brand";v="99.0.0.0", "Google Chrome";v="134", "Chromium";v="134"' \ -H 'priority: u=0, i' \ --compressed 'https://www.domai.name/' ``` --- ## ✅ Fix Implemented The issue occurred because `yargs-parser` treated the URL as a value for the `--compressed` flag. To fix this, the parser configuration was updated to explicitly mark `--compressed` as a **boolean flag**, ensuring it doesn’t capture the next token (the URL). ### **Code Change** ```ts const args: parser.Arguments = parser(curlCommand, { boolean: ["compressed"], configuration: { "parse-numbers": false, "camel-case-expansion": false, "boolean-negation": false, }, }) ``` --- ### ⚙️ **2️⃣ Configuration Explanation** Show what each option does and why it matters. --- ## ⚙️ Configuration Explanation | Option | Default | Updated | Description | |---------|----------|----------|--------------| | `boolean: ["compressed"]` | — | ✅ Added | Ensures `--compressed` is a standalone flag, not consuming the next value (URL) | | `"parse-numbers": false` | true | ✅ false | Keeps all values as strings; avoids unintended type conversion | | `"camel-case-expansion": false` | true | ✅ false | Keeps flag names unchanged (e.g., `--data-urlencode` stays the same) | | `"boolean-negation": false` | true | ✅ false | Prevents negation of flags like `--no-keepalive` | --- ## 🧪 Verification ### ✅ Test Case 1 — Original Input ```bash curl -H 'Host: www.domai.name' \ -H 'Cookie: GUID=abc123zxcasdqwe' \ -H 'sec-fetch-user: ?1' \ -H 'sec-fetch-dest: document' \ -H 'sec-ch-ua-full-version-list: "(Not(A:Brand";v="99.0.0.0", "Google Chrome";v="134", "Chromium";v="134"' \ -H 'priority: u=0, i' \ --compressed 'https://www.domai.name/' ``` ### ✅ Test Case 2 — POST Request with JSON Body and Cookies ```bash curl -X POST 'https://api.example.com/v1/users' \ -H 'Host: api.example.com' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer abc123tokenxyz' \ -H 'User-Agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_0_0)"' \ -H 'accept-language: en-US,en;q=0.9' \ -H 'x-request-id: 98765' \ --cookie 'sessionid=xyz789; theme=dark' \ --compressed \ -d '{"name": "Ankur", "email": "ankur@example.com", "role": "frontend"}' ``` --- ### 🧾 Change Type | Type | Scope | Impact | |------|--------|---------| | 🐞 Bug Fix | `helpers/curl/curlparser.ts` | Fixes URL parsing issue for `--compressed` flag | --- ## 👨‍💻 Author **@ankur-2103** Fixed boolean flag handling for `--compressed` in the cURL import parser. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#5265
No description provided.