Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

curl-to-postmanv2

Package Overview
Dependencies
Maintainers
6
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

curl-to-postmanv2 - npm Package Compare versions

Comparing version 1.7.1 to 1.8.0

11

CHANGELOG.md

@@ -5,2 +5,9 @@ # cURL to Postman Importer Changelog

## [v1.8.0] - 2024-01-17
### Changed
- Fix for - [#12349](https://github.com/postmanlabs/postman-app-support/issues/12349) Fixed issue where GraphQL requests were failing to send correct data.
- Fixed various TypeErrors that were occurring frequently for users.
## [v1.7.1] - 2023-07-17

@@ -119,4 +126,6 @@

[Unreleased]: https://github.com/postmanlabs/curl-to-postman/compare/v1.7.1...HEAD
[Unreleased]: https://github.com/postmanlabs/curl-to-postman/compare/v1.8.0...HEAD
[v1.8.0]: https://github.com/postmanlabs/curl-to-postman/compare/v1.7.1...v1.8.0
[v1.7.1]: https://github.com/postmanlabs/curl-to-postman/compare/v1.7.0...v1.7.1

@@ -123,0 +132,0 @@

4

package.json
{
"name": "curl-to-postmanv2",
"version": "1.7.1",
"version": "1.8.0",
"description": "Convert a given CURL command to a Postman request",

@@ -16,3 +16,3 @@ "main": "index.js",

"commander": "2.20.3",
"lodash": "^4.17.11",
"lodash": "4.17.21",
"shell-quote": "1.6.1",

@@ -19,0 +19,0 @@ "uuid": "3.2.1",

@@ -108,9 +108,14 @@ const commander = require('commander'),

singleWordXMethod,
singleWordMethodPrefix = '-X';
if (validMethods.indexOf(curlObj.request.toUpperCase()) === -1) {
singleWordMethodPrefix = '-X',
reqMethod = _.toUpper(curlObj.request);
if (validMethods.indexOf(reqMethod) === -1) {
// no valid method
// -XPOST might have been used
// try the POST part again
singleWordXMethod = _.find(curlObj.rawArgs, function (arg) { return arg.startsWith(singleWordMethodPrefix); });
singleWordXMethod = _.find(curlObj.rawArgs, function (arg) {
return typeof arg === 'string' && arg.startsWith(singleWordMethodPrefix);
});
if (singleWordXMethod) {

@@ -121,3 +126,5 @@ // try to re-set curlObj.request to the newly extracted method

if (validMethods.indexOf(curlObj.request.toUpperCase()) === -1) {
reqMethod = _.toUpper(curlObj.request);
if (validMethods.indexOf(reqMethod) === -1) {
// the method is still not valid

@@ -223,3 +230,3 @@ throw new UserError(USER_ERRORS.METHOD_NOT_SUPPORTED`${curlObj.request}`);

// It is a valid cURL to have only username, in that case keep password empty
const userParts = curlObj.user.split(':') || [];
const userParts = (typeof curlObj.user === 'string' && curlObj.user.split(':')) || [];
if (userParts.length === 1) {

@@ -535,2 +542,7 @@ userParts[1] = '';

// if correct boundary match is not found, keep formdata fields empty
if (!m || typeof data !== 'string') {
return parsedFormData;
}
// \r\n is part of the boundary.

@@ -646,3 +658,3 @@ boundary = '\r\n--' + (m[1] || m[2]);

// if method is not given in the curl command
if (!curlObj.request) {
if (typeof curlObj.request !== 'string' || !curlObj.request) {
curlObj.request = this.getRequestMethod(curlObj);

@@ -713,2 +725,3 @@ isMethodGuessed = true;

const rawDataObj = _.attempt(JSON.parse, this.escapeJson(dataString));
if (contentType === 'application/json' && rawDataObj && !_.isError(rawDataObj)) {

@@ -730,7 +743,5 @@ if (!_.has(rawDataObj, 'query') || !_.isString(rawDataObj.query)) {

}
delete rawDataObj.operationName;
}
else {
rawDataObj.operationName = '';
}
if (_.keys(rawDataObj).length === 3) {
if (_.keys(rawDataObj).length === 2) {
const graphqlVariables = JSON.stringify(rawDataObj.variables, null, 2);

@@ -741,3 +752,2 @@ return {

query: rawDataObj.query,
operationName: rawDataObj.operationName,
variables: graphqlVariables === '{}' ? '' : graphqlVariables

@@ -744,0 +754,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc