Skip to content

Commit

Permalink
fixed failure when params have an object with key = toString (#3)
Browse files Browse the repository at this point in the history
* fixed failure when params have an object with key = toString
  • Loading branch information
Eli-Siegel1 authored Mar 7, 2022
1 parent 7cb4de5 commit 3805f96
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion lib/parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ Object.assign(Parameters, {

_isPrimitive: function (value) {
return PRIMITIVE_TYPES.some(function (Primitive) {
return [typeof value, String(value)].some(function (val) { return val === Primitive.name.toLowerCase() })
let initValue;
try {
initValue = String(value)
} catch (error) {
initValue = '';
}
return [typeof value, initValue].some(function (val) { return val === Primitive.name.toLowerCase() })
})
},

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "strong-params",
"version": "1.0.3",
"version": "1.0.4",
"description": "Rails-style strong parameters for javascript projects. (e.g. Express, Koa)",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 3805f96

Please sign in to comment.