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

This commit is contained in:
Stéfany Larissa 2025-02-19 04:48:02 -03:00 committed by GitHub
parent 6d21c8c9eb
commit bb36d32359
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 43 additions and 0 deletions

View file

@ -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", () => {

View file

@ -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),