fix(curl): properly wrap JSON payload (#31)
This commit is contained in:
@@ -55,7 +55,7 @@ describe('generateCurlCommand', () => {
|
||||
expect(command).toContain('"https://api.example.com/users?page=1"');
|
||||
expect(command).toContain('-H "Authorization: Bearer token"');
|
||||
expect(command).toContain('-H "Accept: application/json"');
|
||||
expect(command).toContain('{"name":"Jane"}');
|
||||
expect(command).toContain('\'{"name":"Jane"}\'');
|
||||
expect(hasSpecialAuth).toBe(false);
|
||||
});
|
||||
|
||||
@@ -98,7 +98,7 @@ describe('generateCurlCommand', () => {
|
||||
expect(command).toContain('-H "Authorization: Bearer token"');
|
||||
expect(command).toContain('-H "Accept: application/json"');
|
||||
expect(command).toContain(
|
||||
'{"user":{"firstName":"Jane","lastName":"Doe"},"username":"foobar"}',
|
||||
'\'{"user":{"firstName":"Jane","lastName":"Doe"},"username":"foobar"}\'',
|
||||
);
|
||||
expect(hasSpecialAuth).toBe(false);
|
||||
});
|
||||
|
||||
@@ -255,7 +255,7 @@ function transformRequestBodyToKeyValuePairs(
|
||||
*/
|
||||
function convertBodyValueToRequestParts(bodyValue: string | FormData): string[] {
|
||||
if (typeof bodyValue === 'string') {
|
||||
return [`-d ${bodyValue}`];
|
||||
return [`-d '${bodyValue}'`];
|
||||
}
|
||||
|
||||
return convertFormDataToCUrlFields(bodyValue);
|
||||
|
||||
Reference in New Issue
Block a user