Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add curl argument: --data-urlencode #1009

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mikecanann
Copy link

Add a command line argument for curl, called: --data-urlencode

@@ -52,7 +52,7 @@ export class CurlRequestParser implements RequestParser {
}

// parse body
let body = parsedArguments.d || parsedArguments.data || parsedArguments['data-ascii'] || parsedArguments['data-binary'] || parsedArguments['data-raw'];
let body = parsedArguments.d || parsedArguments.data || parsedArguments['data-ascii'] || parsedArguments['data-binary'] || parsedArguments['data-raw'] || parsedArguments['data-urlencode'];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this case, do we need to do the URL encode work explictly?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that has been added to the PR

Copy link

@bolthorn91 bolthorn91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a little improvement for future purposes

@@ -52,7 +52,7 @@ export class CurlRequestParser implements RequestParser {
}

// parse body
let body = parsedArguments.d || parsedArguments.data || parsedArguments['data-ascii'] || parsedArguments['data-binary'] || parsedArguments['data-raw'];
let body = parsedArguments.d || parsedArguments.data || parsedArguments['data-ascii'] || parsedArguments['data-binary'] || parsedArguments['data-raw'] || parsedArguments['data-urlencode'];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about putting all arguments in array in order to scale or abstract if we need it? for example:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let body = parsedArguments.d || parsedArguments.data || parsedArguments['data-ascii'] || parsedArguments['data-binary'] || parsedArguments['data-raw'] || parsedArguments['data-urlencode'];
const dataKeys = ['d', 'data', 'data-ascii', 'data-binary', 'data-raw', 'data-urlencode'];
let body = parsedArguments[dataKeys.find(key => !!parsedArguments[key])];

@mikecanann mikecanann requested review from Huachao and bolthorn91 and removed request for Huachao March 22, 2023 17:24
Copy link

@bolthorn91 bolthorn91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GJ!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants