Skip to content

Commit 3805f96

Browse files
authored
fixed failure when params have an object with key = toString (#3)
* fixed failure when params have an object with key = toString
1 parent 7cb4de5 commit 3805f96

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

lib/parameters.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,13 @@ Object.assign(Parameters, {
6262

6363
_isPrimitive: function (value) {
6464
return PRIMITIVE_TYPES.some(function (Primitive) {
65-
return [typeof value, String(value)].some(function (val) { return val === Primitive.name.toLowerCase() })
65+
let initValue;
66+
try {
67+
initValue = String(value)
68+
} catch (error) {
69+
initValue = '';
70+
}
71+
return [typeof value, initValue].some(function (val) { return val === Primitive.name.toLowerCase() })
6672
})
6773
},
6874

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "strong-params",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "Rails-style strong parameters for javascript projects. (e.g. Express, Koa)",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)