Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/insomnia/src/main/importers/importers/curl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ describe('curl', () => {
curl: "curl -X POST https://example.com -H 'Content-Type: application/x-www-form-urlencoded' --data-urlencode '%3D'",
expected: { body: { params: [{ name: '', value: '%3D' }] } },
},
{
name: 'should handle multipart text fields with multiple equals signs',
curl: "curl -X POST https://example.com -F 'token=abc=def=='",
expected: { body: { params: [{ name: 'token', value: 'abc=def==', type: 'text' }] } },
},
{
name: 'should handle multipart file fields with equals signs in the file path',
curl: "curl -X POST https://example.com -F 'file=@/tmp/a=b.txt'",
expected: { body: { params: [{ name: 'file', fileName: '/tmp/a=b.txt', type: 'file' }] } },
},

// --data flags without urlencoded content type
{
Expand Down
4 changes: 3 additions & 1 deletion packages/insomnia/src/main/importers/importers/curl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ const extractBody = (
...((pairsByName.form as string[] | undefined) || []),
...((pairsByName.F as string[] | undefined) || []),
].map(str => {
const [name, value] = str.split('=');
const equalIndex = str.indexOf('=');
const name = equalIndex === -1 ? str : str.slice(0, equalIndex);
const value = equalIndex === -1 ? '' : str.slice(equalIndex + 1);
const item: Parameter = {
name,
};
Expand Down