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

Repair json parsing issues. #49

Merged
merged 3 commits into from
Jun 6, 2018
Merged

Repair json parsing issues. #49

merged 3 commits into from
Jun 6, 2018

Conversation

will-in-wi
Copy link
Contributor

Fixes #48

CHANGELOG.md Outdated
@@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Your contribution here!

### Bugfix

Choose a reason for hiding this comment

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

### Fixed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, it's been fixed

@@ -116,7 +116,9 @@ def make_request(verb_klass, uri, options, step = 0)

def build_response(&block)
response = yield
Drip::Response.new(response.code.to_i, response.body)
Drip::Response.new(response.code.to_i, response.body ? JSON.parse(response.body) : nil)

Choose a reason for hiding this comment

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

Could response.body be an empty string? If so, could use present?. Or could response.body every be false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Empty string triggers the JSON::ParserError and returns nil, which is correct.

It can't be false, and if it were, the result should be nil.

#present? comes from ActiveSupport, which we don't use here.

I've improved the empty string case to not require an exception, and added a test (which passed before the change).

@will-in-wi will-in-wi merged commit 56e1269 into master Jun 6, 2018
@will-in-wi will-in-wi deleted the repair_json_parsing branch June 6, 2018 21:14
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.

None yet

6 participants