Skip to content

Commit

Permalink
Fix parsing urlencoded pairs with empty values. (#6980)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamroyle authored Apr 11, 2024
1 parent c562d15 commit 0a2187f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/insomnia/src/utils/importers/importers/curl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '>' }] },
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia/src/utils/importers/importers/curl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

Expand Down

0 comments on commit 0a2187f

Please sign in to comment.