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

Added 'smart' and 'force' modes to json option. #70

Merged
merged 2 commits into from Feb 13, 2015
Merged

Conversation

@arb
Copy link
Contributor

arb commented Jan 8, 2015

Trumps #68 because that will still look at the content-type header even in 'force' mode. My change does not and tries to parse regardless of the header. Which was the goal of #67 I believe.

@arb arb assigned geek Jan 8, 2015
@arb arb changed the title Added 'smart' and 'force' modes to json option. Closes #67 Added 'smart' and 'force' modes to json option. Jan 8, 2015
@geek geek added this to the 5.2.0 milestone Jan 8, 2015
@geek geek added the feature label Jan 8, 2015
return callback(null, buffer);
}
var result;
var mode = (options.json === true || options.json.toLowerCase() === 'smart') ? 'smart' : 'force';

This comment has been minimized.

Copy link
@geek

geek Jan 8, 2015

Member

doesn't seem like you need this line, could check options.json === 'force' directly on line 232

This comment has been minimized.

Copy link
@arb

arb Jan 9, 2015

Author Contributor

Heh, good point!

err: null
};
try {
var json = JSON.parse(buffer.toString());

This comment has been minimized.

Copy link
@geek

geek Jan 8, 2015

Member

why not assign directly to result.json

This comment has been minimized.

Copy link
@arb

arb Jan 9, 2015

Author Contributor

I think it reads a little easier as is. It's obvious that if the parse fails, json will be null. I can change it though if need be.

@legomind

This comment has been minimized.

Copy link

legomind commented Jan 9, 2015

Sweet.

geek added a commit that referenced this pull request Feb 13, 2015
Added 'smart' and 'force' modes to json option.
@geek geek merged commit 1c9c05f into hapijs:master Feb 13, 2015
1 check passed
1 check passed
continuous-integration/travis-ci The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.