Fix parsing urlencoded pairs with empty values.
There is a bug with parsing curl statements with empty values. This fixes the bug and adjusts the tests to expected behavior.
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.
Hi @adamroyle thanks for submitting this! We're eager to help you get this into a merged state.
While I was testing this PR out locally I've found some cases where we will still not properly render urlencoded pairs. Can you provide an example you used for testing this PR?
I'm just using a simple example:
curl 'http://localhost/' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-raw 'param1=¶m2=¶m3=value'
As an aside, however, I found another issue where Bash-style ANSI-C quoted strings (eg. --data-raw $'....') were not decoded properly. Google Chrome's "Copy as cURL" feature uses them for JSON strings that contain special chars.
eg.
curl 'http://localhost/' \
-H 'Content-Type: application/json;charset=UTF-8' \
--data-raw $'{"name":"O\'Reilly"}'
I spent a while trying to get it to work but ran into too many issues (mainly with general shell parsing libraries not implementing Bash-style quotes), and instead built a parser for "Copy as fetch (Node.js)" instead which has been much more reliable.