From 384aabf2af297aede5e367a848520318c7b25bbf Mon Sep 17 00:00:00 2001 From: Tanishq Singla Date: Wed, 29 Oct 2025 14:11:46 +0530 Subject: [PATCH] Bugfix: Error importing curl with no space in header (#5897) * fix: error importing curl when there is no space in header --- packages/bruno-app/src/utils/curl/parse-curl.js | 2 +- .../bruno-app/src/utils/curl/parse-curl.spec.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/bruno-app/src/utils/curl/parse-curl.js b/packages/bruno-app/src/utils/curl/parse-curl.js index 558611810..cf499d187 100644 --- a/packages/bruno-app/src/utils/curl/parse-curl.js +++ b/packages/bruno-app/src/utils/curl/parse-curl.js @@ -186,7 +186,7 @@ const handleValue = (value, state, request) => { * Set header from value */ const setHeader = (request, value) => { - const [headerName, headerValue] = value.split(/: (.+)/); + const [headerName, headerValue] = value.split(/:\s*(.+)/); request.headers[headerName] = headerValue; }; diff --git a/packages/bruno-app/src/utils/curl/parse-curl.spec.js b/packages/bruno-app/src/utils/curl/parse-curl.spec.js index 7e8cff58a..e0da77d37 100644 --- a/packages/bruno-app/src/utils/curl/parse-curl.spec.js +++ b/packages/bruno-app/src/utils/curl/parse-curl.spec.js @@ -80,6 +80,21 @@ describe('parseCurlCommand', () => { }); }); + it('should parse single header (no space in header value)', () => { + const result = parseCurlCommand(` + curl --header "Content-Type:application/json" https://api.example.com + `); + + expect(result).toEqual({ + method: 'get', + headers: { + 'Content-Type': 'application/json' + }, + url: 'https://api.example.com', + urlWithoutQuery: 'https://api.example.com' + }); + }); + it('should parse multiple headers', () => { const result = parseCurlCommand(` curl -H "Content-Type: application/json" \