cojs / co-body

Parse request bodies with co
MIT License
325 stars 42 forks source link

"Strict" Option for JSON does not work #45

Closed alqu closed 7 years ago

alqu commented 8 years ago

Hi,

I noticed that there is a bug in here: https://github.com/cojs/co-body/blob/master/lib/json.js#L50

It should be if (!strict) return str; instead of if (!strict) return str ? JSON.parse(str) : str;

Please fix :-)

alqu commented 8 years ago

...or: does it mean: "if we have no strict mode setting, then -if the string is somewhat trueish - parse it?

Then I did not understand the logic in the first place.

dead-horse commented 7 years ago

strict mode will ensure this.request.body always be an object.