mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
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:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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" \
|
||||
|
||||
Reference in New Issue
Block a user