Skip to content

Commit 9d12d6e

Browse files
committed
fix: preserve equals in curl form imports
1 parent c08b1b7 commit 9d12d6e

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

packages/insomnia/src/main/importers/importers/curl.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,16 @@ describe('curl', () => {
186186
curl: "curl -X POST https://example.com -H 'Content-Type: application/x-www-form-urlencoded' --data-urlencode '%3D'",
187187
expected: { body: { params: [{ name: '', value: '%3D' }] } },
188188
},
189+
{
190+
name: 'should handle multipart text fields with multiple equals signs',
191+
curl: "curl -X POST https://example.com -F 'token=abc=def=='",
192+
expected: { body: { params: [{ name: 'token', value: 'abc=def==', type: 'text' }] } },
193+
},
194+
{
195+
name: 'should handle multipart file fields with equals signs in the file path',
196+
curl: "curl -X POST https://example.com -F 'file=@/tmp/a=b.txt'",
197+
expected: { body: { params: [{ name: 'file', fileName: '/tmp/a=b.txt', type: 'file' }] } },
198+
},
189199

190200
// --data flags without urlencoded content type
191201
{

packages/insomnia/src/main/importers/importers/curl.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ const extractBody = (
168168
...((pairsByName.form as string[] | undefined) || []),
169169
...((pairsByName.F as string[] | undefined) || []),
170170
].map(str => {
171-
const [name, value] = str.split('=');
171+
const equalIndex = str.indexOf('=');
172+
const name = equalIndex === -1 ? str : str.slice(0, equalIndex);
173+
const value = equalIndex === -1 ? '' : str.slice(equalIndex + 1);
172174
const item: Parameter = {
173175
name,
174176
};

0 commit comments

Comments
 (0)