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

Fix for -X<Method> parsing #26

Merged
merged 5 commits into from
Mar 27, 2020
Merged

Fix for -X<Method> parsing #26

merged 5 commits into from
Mar 27, 2020

Conversation

shreys7
Copy link
Member

@shreys7 shreys7 commented Mar 17, 2020

This PR fixes postmanlabs/postman-app-support#7806

Issue:
Hardcoded regex match logic for replacing -XPOST with -X POST was present insanitizeArgs function for the commander to parse the method correctly. This causes problems as if -X is present in header/domain/body, it would replace it too

Fix:

  1. Loop through the sanitizedArgs array
  2. Find an index i that matches the pattern -X* and not exactly equal to -X.
  3. Look at index i-1, if that is not one of the supported args registered in commander, then it suggests it would be for the method name.
  4. Split the arg and get the method name, insert it at index i+1 and set value at index i to be -X.

Example:

sanitizedArgs = ['curl', '-XPOST', 'https://domain.com', '-H', 'key: -Xvalue']

after the above steps:

sanitizedArgs = ['curl', '-X', 'POST', 'https://domain.com', '-H', 'key: -Xvalue']

@abhijitkane abhijitkane merged commit eb4c6c5 into develop Mar 27, 2020
@VShingala VShingala deleted the bugfix/-Xargs branch October 18, 2021 05:59
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.

Could not properly import curl with "X-XSRF-TOKEN"
2 participants