Skip to content

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

feat: import authorization header with curl (#4963)

Chhavi Goyalb6e2e9345767
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 91d9b4d8c..131920577 100644
--- a/packages/hoppscotch-common/src/helpers/curl/__tests__/curlparser.spec.js
+++ b/packages/hoppscotch-common/src/helpers/curl/__tests__/curlparser.spec.js
@@ -312,7 +312,14 @@ const samples = [
body: null,
},
params: [],
- headers: [],
+ headers: [
+ {
+ active: true,
+ key: "Authorization",
+ value: "Basic dXNlcjpwYXNz",
+ description: "",
+ },
+ ],
preRequestScript: "",
testScript: "",
requestVariables: [],
@@ -335,7 +342,14 @@ const samples = [
body: null,
},
params: [],
- headers: [],
+ headers: [
+ {
+ active: true,
+ key: "Authorization",
+ value: "Basic 77898dXNlcjpwYXNz",
+ description: "",
+ },
+ ],
preRequestScript: "",
testScript: "",
requestVariables: [],
@@ -360,7 +374,15 @@ const samples = [
body: null,
},
params: [],
- headers: [],
+ headers: [
+ {
+ active: true,
+ key: "Authorization",
+ value:
+ "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
+ description: "",
+ },
+ ],
preRequestScript: "",
testScript: "",
requestVariables: [],
@@ -980,6 +1002,12 @@ data2: {"type":"test2","typeId":"123"}`,
},
params: [],
headers: [
+ {
+ active: true,
+ key: "Authorization",
+ value: "Basic YXNkZmdoOjEyMzQ=",
+ description: "",
+ },
{
active: true,
key: "User-Agent",
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 fb839cc09..99cb5212a 100644
--- a/packages/hoppscotch-common/src/helpers/curl/sub_helpers/headers.ts
+++ b/packages/hoppscotch-common/src/helpers/curl/sub_helpers/headers.ts
@@ -70,9 +70,6 @@ export const recordToHoppHeaders = (
description: "",
})),
A.filter(
- (header) =>
- header.key !== "Authorization" &&
- header.key !== "content-type" &&
- header.key !== "Content-Type"
+ (header) => header.key !== "content-type" && header.key !== "Content-Type"
)
)