From 1bdf78f0563a3a2d8ecfe49b05d65b0512475c0a Mon Sep 17 00:00:00 2001 From: Adam Royle Date: Thu, 11 Jan 2024 14:35:50 +1000 Subject: [PATCH] Fix parsing urlencoded pairs with empty values. --- packages/insomnia/src/utils/importers/importers/curl.test.ts | 4 ++-- packages/insomnia/src/utils/importers/importers/curl.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/insomnia/src/utils/importers/importers/curl.test.ts b/packages/insomnia/src/utils/importers/importers/curl.test.ts index bacd314b89c..98f1ee18ff3 100644 --- a/packages/insomnia/src/utils/importers/importers/curl.test.ts +++ b/packages/insomnia/src/utils/importers/importers/curl.test.ts @@ -123,7 +123,7 @@ describe('curl', () => { { flag: '--data-urlencode', inputs: ['=value'], expected: [{ name: '', value: 'value' }] }, // --data-urlencode URI encoding - { flag: '--data-urlencode', inputs: ['a='], expected: [{ name: '', value: 'a=' }] }, + { flag: '--data-urlencode', inputs: ['a='], expected: [{ name: 'a', value: '' }] }, { flag: '--data-urlencode', inputs: [' '], expected: [{ name: '', value: ' ' }] }, { flag: '--data-urlencode', inputs: ['<'], expected: [{ name: '', value: '<' }] }, { flag: '--data-urlencode', inputs: ['>'], expected: [{ name: '', value: '>' }] }, @@ -133,7 +133,7 @@ describe('curl', () => { { flag: '--data-urlencode', inputs: ['|'], expected: [{ name: '', value: '|' }] }, { flag: '--data-urlencode', inputs: ['^'], expected: [{ name: '', value: '^' }] }, { flag: '--data-urlencode', inputs: ['"'], expected: [{ name: '', value: '"' }] }, - { flag: '--data-urlencode', inputs: ['='], expected: [{ name: '', value: '=' }] }, + { flag: '--data-urlencode', inputs: ['='], expected: [{ name: '', value: '' }] }, { flag: '--data-urlencode', inputs: ['%3D'], expected: [{ name: '', value: '%3D' }] }, ])('handles %p correctly', async ({ flag, diff --git a/packages/insomnia/src/utils/importers/importers/curl.ts b/packages/insomnia/src/utils/importers/importers/curl.ts index 656540907b0..b6fa85d99e1 100644 --- a/packages/insomnia/src/utils/importers/importers/curl.ts +++ b/packages/insomnia/src/utils/importers/importers/curl.ts @@ -348,7 +348,7 @@ const pairToParameters = (pair: Pair, allowFiles = false): Parameter[] => { } const [name, value] = pair.split('='); - if (!value || !pair.includes('=')) { + if (!value && !pair.includes('=')) { return { name: '', value: pair }; }