Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix: cURL header imports without trailing space (#4724)

Stéfany Larissabb36d3235914
diff --git a/packages/hoppscotch-common/src/helpers/curl/__tests__/curlparser.spec.js b/packages/hoppscotch-common/src/helpers/curl/__tests__/curlparser.spec.js
index 4b12a5d5f..91d9b4d8c 100644
--- a/packages/hoppscotch-common/src/helpers/curl/__tests__/curlparser.spec.js
+++ b/packages/hoppscotch-common/src/helpers/curl/__tests__/curlparser.spec.js
@@ -958,6 +958,48 @@ data2: {"type":"test2","typeId":"123"}`,
responses: {},
}),
},
+ {
+ command: `curl --request GET \
+ --url https://echo.hoppscotch.io/ \
+ --header 'Authorization:Basic YXNkZmdoOjEyMzQ=' \
+ --header 'User-Agent:Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0'
+ --header 'foo:bar'`,
+ response: makeRESTRequest({
+ method: "GET",
+ name: "Untitled",
+ endpoint: "https://echo.hoppscotch.io/",
+ auth: {
+ authType: "basic",
+ authActive: true,
+ username: "asdfgh",
+ password: "1234",
+ },
+ body: {
+ contentType: null,
+ body: null,
+ },
+ params: [],
+ headers: [
+ {
+ active: true,
+ key: "User-Agent",
+ value:
+ "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0",
+ description: "",
+ },
+ {
+ active: true,
+ key: "foo",
+ value: "bar",
+ description: "",
+ },
+ ],
+ preRequestScript: "",
+ testScript: "",
+ requestVariables: [],
+ responses: {},
+ }),
+ },
]
describe("Parse curl command to Hopp REST Request", () => {
diff --git a/packages/hoppscotch-common/src/helpers/curl/sub_helpers/headers.ts b/packages/hoppscotch-common/src/helpers/curl/sub_helpers/headers.ts
index 5135729a8..fb839cc09 100644
--- a/packages/hoppscotch-common/src/helpers/curl/sub_helpers/headers.ts
+++ b/packages/hoppscotch-common/src/helpers/curl/sub_helpers/headers.ts
@@ -11,6 +11,7 @@ import {
import { tupleToRecord } from "~/helpers/functional/record"
const getHeaderPair = flow(
+ S.replace(":", ": "),
S.split(": "),
// must have a key and a value
O.fromPredicate((arr) => arr.length === 2),