mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-07 08:34:15 +01:00
fix(1548): correct import of escaped curl string (#1549)
This commit is contained in:
parent
7cf5f0d612
commit
808af3c19a
@ -59,4 +59,20 @@ describe('curlToJson', () => {
|
||||
data: '{"email":"test@usebruno.com","password":"test"}'
|
||||
});
|
||||
});
|
||||
|
||||
it('should accept escaped curl string', () => {
|
||||
const curlCommand = `curl https://www.usebruno.com
|
||||
-H $'cookie: val_1=\'\'; val_2=\\^373:0\\^373:0; val_3=\u0068\u0065\u006C\u006C\u006F'
|
||||
`;
|
||||
const result = curlToJson(curlCommand);
|
||||
|
||||
expect(result).toEqual({
|
||||
url: 'https://www.usebruno.com',
|
||||
raw_url: 'https://www.usebruno.com',
|
||||
method: 'get',
|
||||
headers: {
|
||||
cookie: "val_1=''; val_2=\\^373:0\\^373:0; val_3=hello"
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -12,6 +12,9 @@ import * as querystring from 'query-string';
|
||||
import yargs from 'yargs-parser';
|
||||
|
||||
const parseCurlCommand = (curlCommand) => {
|
||||
// catch escape sequences (e.g. -H $'cookie: it=\'\'')
|
||||
curlCommand = curlCommand.replace(/\$('.*')/g, (match, group) => group);
|
||||
|
||||
// Remove newlines (and from continuations)
|
||||
curlCommand = curlCommand.replace(/\\\r|\\\n/g, '');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user