[PR #5914] [CLOSED] fix(curl): handle output-control flags in curl import #5415

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

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5914
Author: @A386official
Created: 2/28/2026
Status: Closed

Base: mainHead: fix/curl-import-output-flags


📝 Commits (2)

  • 23d21f4 fix(curl): handle output-control flags in curl import
  • f4c54ee fix(curlparser): add -G and long-form boolean flags

📊 Changes

2 files changed (+139 additions, -1 deletions)

View changed files

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

📄 Description

Fixes #5910

What's going on

When you paste a curl command with flags like -sS, -v, or -k, the import fails with "cURL is not formatted properly". This happens because yargs-parser doesn't know these are boolean flags, so it treats the next argument as their value. If that next argument is the URL, it gets swallowed and the parser can't find it.

For example, curl -sS https://example.com gets parsed as:

{ "_": ["curl"], "s": true, "S": "https://example.com" }

The URL ends up as the value of -S instead of in the positional args where getURLObject looks for it.

Fix

Pass a boolean config to yargs-parser listing the curl flags that don't take arguments:

-s, -S, -v, -k, -L, -N, -f, -q, -n, -#, -0, -4, -6

These are all output/behavior flags that don't affect the HTTP request itself. After the fix:

{ "_": ["curl", "https://example.com"], "s": true, "S": true }

Tests

Added 3 test cases:

  • curl -sS <url> (the exact case from the issue)
  • curl -sSL -k -H '...' <url> (combined flags with headers)
  • curl -v <url> (verbose flag)

All 32 tests pass (29 existing + 3 new).


Summary by cubic

Fixes curl import failures by treating non-argument flags (short and long) as booleans so the URL isn’t swallowed. This resolves “cURL is not formatted properly” for commands using combined flags like -sS, -v, -k, -G, -I, and their long forms.

  • Bug Fixes
    • Configure yargs-parser boolean flags: short (-s, -S, -v, -k, -L, -I, -G, -N, -f, -q, -n, -#, -0, -4, -6) and long (--silent, --show-error, --verbose, --insecure, --location, --head, --get, --no-buffer, --fail, --disable, --netrc, --progress-bar, --ipv4, --ipv6, --compressed).
    • Keeps the URL in positional args, enabling imports with combined flags.
    • Adds tests for -sS , -sSL -k with headers, -v , -G , and --silent --verbose .

Written for commit f4c54eeffb. Summary will update on new commits.


🔄 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/5914 **Author:** [@A386official](https://github.com/A386official) **Created:** 2/28/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/curl-import-output-flags` --- ### 📝 Commits (2) - [`23d21f4`](https://github.com/hoppscotch/hoppscotch/commit/23d21f46615f57ba30f83831eb9462b3cb79d25b) fix(curl): handle output-control flags in curl import - [`f4c54ee`](https://github.com/hoppscotch/hoppscotch/commit/f4c54eeffb4f8d980789b2254feb8b7b7aa6da07) fix(curlparser): add -G and long-form boolean flags ### 📊 Changes **2 files changed** (+139 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-common/src/helpers/curl/__tests__/curlparser.spec.js` (+102 -0) 📝 `packages/hoppscotch-common/src/helpers/curl/curlparser.ts` (+37 -1) </details> ### 📄 Description Fixes #5910 ## What's going on When you paste a curl command with flags like `-sS`, `-v`, or `-k`, the import fails with "cURL is not formatted properly". This happens because `yargs-parser` doesn't know these are boolean flags, so it treats the next argument as their value. If that next argument is the URL, it gets swallowed and the parser can't find it. For example, `curl -sS https://example.com` gets parsed as: ```json { "_": ["curl"], "s": true, "S": "https://example.com" } ``` The URL ends up as the value of `-S` instead of in the positional args where `getURLObject` looks for it. ## Fix Pass a `boolean` config to `yargs-parser` listing the curl flags that don't take arguments: `-s`, `-S`, `-v`, `-k`, `-L`, `-N`, `-f`, `-q`, `-n`, `-#`, `-0`, `-4`, `-6` These are all output/behavior flags that don't affect the HTTP request itself. After the fix: ```json { "_": ["curl", "https://example.com"], "s": true, "S": true } ``` ## Tests Added 3 test cases: - `curl -sS <url>` (the exact case from the issue) - `curl -sSL -k -H '...' <url>` (combined flags with headers) - `curl -v <url>` (verbose flag) All 32 tests pass (29 existing + 3 new). <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes curl import failures by treating non-argument flags (short and long) as booleans so the URL isn’t swallowed. This resolves “cURL is not formatted properly” for commands using combined flags like -sS, -v, -k, -G, -I, and their long forms. - **Bug Fixes** - Configure yargs-parser boolean flags: short (-s, -S, -v, -k, -L, -I, -G, -N, -f, -q, -n, -#, -0, -4, -6) and long (--silent, --show-error, --verbose, --insecure, --location, --head, --get, --no-buffer, --fail, --disable, --netrc, --progress-bar, --ipv4, --ipv6, --compressed). - Keeps the URL in positional args, enabling imports with combined flags. - Adds tests for -sS <url>, -sSL -k with headers, -v <url>, -G <url>, and --silent --verbose <url>. <sup>Written for commit f4c54eeffb4f8d980789b2254feb8b7b7aa6da07. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:51:46 +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#5415
No description provided.