Skip to content

Commit b6e2e93

Browse files
authored
feat: import authorization header with curl (hoppscotch#4963)
1 parent 9e8ecd9 commit b6e2e93

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

packages/hoppscotch-common/src/helpers/curl/__tests__/curlparser.spec.js

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,14 @@ const samples = [
312312
body: null,
313313
},
314314
params: [],
315-
headers: [],
315+
headers: [
316+
{
317+
active: true,
318+
key: "Authorization",
319+
value: "Basic dXNlcjpwYXNz",
320+
description: "",
321+
},
322+
],
316323
preRequestScript: "",
317324
testScript: "",
318325
requestVariables: [],
@@ -335,7 +342,14 @@ const samples = [
335342
body: null,
336343
},
337344
params: [],
338-
headers: [],
345+
headers: [
346+
{
347+
active: true,
348+
key: "Authorization",
349+
value: "Basic 77898dXNlcjpwYXNz",
350+
description: "",
351+
},
352+
],
339353
preRequestScript: "",
340354
testScript: "",
341355
requestVariables: [],
@@ -360,7 +374,15 @@ const samples = [
360374
body: null,
361375
},
362376
params: [],
363-
headers: [],
377+
headers: [
378+
{
379+
active: true,
380+
key: "Authorization",
381+
value:
382+
"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
383+
description: "",
384+
},
385+
],
364386
preRequestScript: "",
365387
testScript: "",
366388
requestVariables: [],
@@ -980,6 +1002,12 @@ data2: {"type":"test2","typeId":"123"}`,
9801002
},
9811003
params: [],
9821004
headers: [
1005+
{
1006+
active: true,
1007+
key: "Authorization",
1008+
value: "Basic YXNkZmdoOjEyMzQ=",
1009+
description: "",
1010+
},
9831011
{
9841012
active: true,
9851013
key: "User-Agent",

packages/hoppscotch-common/src/helpers/curl/sub_helpers/headers.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ export const recordToHoppHeaders = (
7070
description: "",
7171
})),
7272
A.filter(
73-
(header) =>
74-
header.key !== "Authorization" &&
75-
header.key !== "content-type" &&
76-
header.key !== "Content-Type"
73+
(header) => header.key !== "content-type" && header.key !== "Content-Type"
7774
)
7875
)

0 commit comments

Comments
 (0)