postmanlabs / curl-to-postman

Converts curl requests to Postman Collection v2 request objects
Apache License 2.0
65 stars 31 forks source link

Fixed an issue where cURL with comments described was converted incorrectly. #56

Closed VShingala closed 1 year ago

VShingala commented 1 year ago

Overview

This PR fixes issue where for certain cURL were converted incorrectly. For example, below cURL imported successfully with incorrect URL and name being object rather than failing as it's invalid cURL. i.e. executing this command will provide following error in bash.

➜  ~ curl -X POST -H 'Content-type: application/json' #{reply_url} --data '#{response.to_json}'
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information

RCA

issue was happening due to incorrect handling of curlObj.args whenever comments were present. We're simply assigning curlObj.args[0] directly as a request URL. Which created object for URL which is incorrect as it should be string.

Fix

We'll be filtering out any comments found in the curlObj.args and also making sure we only assign string values to request URL.