Bugfix: Error importing curl with no space in header (#5897)

* fix: error importing curl when there is no space in header
This commit is contained in:
Tanishq Singla
2025-10-29 14:11:46 +05:30
committed by GitHub
parent a15dcdb133
commit 384aabf2af
2 changed files with 16 additions and 1 deletions

View File

@@ -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;
};

View File

@@ -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" \