From 9d12d6eacac25902fcd0377f0a9f34daff5b2a2d Mon Sep 17 00:00:00 2001 From: immanuwell Date: Tue, 26 May 2026 19:05:02 +0400 Subject: [PATCH] fix: preserve equals in curl form imports --- .../insomnia/src/main/importers/importers/curl.test.ts | 10 ++++++++++ packages/insomnia/src/main/importers/importers/curl.ts | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/insomnia/src/main/importers/importers/curl.test.ts b/packages/insomnia/src/main/importers/importers/curl.test.ts index 87c15fe3d273..14a0baa005e3 100644 --- a/packages/insomnia/src/main/importers/importers/curl.test.ts +++ b/packages/insomnia/src/main/importers/importers/curl.test.ts @@ -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 { diff --git a/packages/insomnia/src/main/importers/importers/curl.ts b/packages/insomnia/src/main/importers/importers/curl.ts index 2481b96193cb..06f98091dd6b 100644 --- a/packages/insomnia/src/main/importers/importers/curl.ts +++ b/packages/insomnia/src/main/importers/importers/curl.ts @@ -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, };