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

Support urlencoded for all methods #77 #83

Merged
merged 2 commits into from
Nov 21, 2014
Merged

Support urlencoded for all methods #77 #83

merged 2 commits into from
Nov 21, 2014

Conversation

tarmolov
Copy link
Member

No description provided.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) when pulling 50cb618 on hevil.urlencoded into 1f45d3d on master.

* @returns {Object}
*/
function parseJson(value, type) {
return typeof value === 'string' && ['array', 'object'].indexOf(type) !== -1 ?
Copy link
Contributor

Choose a reason for hiding this comment

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

parseJson is never called with other types, why do you need this check here?
Seems that type parameter is not needed at all.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not all folks pass arrays and objects in string representation.

JSON.parse([1,2]); // Uncaught SyntaxError: Unexpected token ,

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, typeof value === 'string' ? is enough

Copy link
Member Author

Choose a reason for hiding this comment

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

Oups. You're right)

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) when pulling 5174af6 on hevil.urlencoded into 1f45d3d on master.

@twoRoger
Copy link
Contributor

I don't like the idea of treating 1, "1", "'1'", [1,2], "false", etc as valid objects, but it's ok for now)

*/
function parseJson(value) {
return typeof value === 'string' ?
JSON.parse(value) :
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add try-catch here and throw some human-friendly error instead of SyntaxError)

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) when pulling c4bc7c8 on hevil.urlencoded into 1f45d3d on master.

@twoRoger
Copy link
Contributor

🤘

@watch-the-stars
Copy link

🆗

@dodev
Copy link
Contributor

dodev commented Nov 21, 2014

👍

tarmolov added a commit that referenced this pull request Nov 21, 2014
Support urlencoded for all methods #77
@tarmolov tarmolov merged commit e502666 into master Nov 21, 2014
@tarmolov tarmolov deleted the hevil.urlencoded branch November 21, 2014 21:46
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.

5 participants