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
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/utils/curlRequestParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

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])];

if (Array.isArray(body)) {
body = body.join('&');
} else {
Expand Down