Skip to content
This repository has been archived by the owner on Jan 12, 2021. It is now read-only.

Better handling of boolean arguments #24

Merged
merged 2 commits into from
Aug 1, 2018
Merged

Better handling of boolean arguments #24

merged 2 commits into from
Aug 1, 2018

Conversation

bengourley
Copy link
Contributor

  • tells the cli argument parser which of the options are boolean flags
  • ensures that the boolean overwrite parameter is not passed through to the API when it is false (this is because the body is a URL encoded form so false gets encoded as "false" which is a truthy value!)

The latter point addresses #23.

// true, so only add it to the payload if it is truthy
if (options.overwrite) {
formData[name] = String(value);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If I make a curl call with overwrite=false, would the API interpret that value as truthy? If so, we should update our docs to make that clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

@@ -297,6 +297,14 @@ function prepareRequest(options) {
case 'tempDir': {
break;
}
case 'overwrite': {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this only apply to overwrite, and not any of the other boolean flags?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only overwrite as that's the only one that gets sent to the API. All of the other boolean args configure the behaviour of this module but don't get put in the payload.

@fractalwrench fractalwrench self-requested a review August 1, 2018 12:37
Copy link
Contributor

@fractalwrench fractalwrench left a comment

Choose a reason for hiding this comment

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

Looks good to me, tests are a nice addition to the project.

The only other thing that I think needs altering is the wording of our API docs, as IMO they imply that setting overwrite as "false" will not overwrite existing maps. https://docs.bugsnag.com/api/js-source-map-upload/

@bengourley bengourley merged commit 04e2846 into master Aug 1, 2018
@bengourley bengourley deleted the boolean-args branch August 1, 2018 14:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants