File tree 1 file changed +6
-2
lines changed
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ module.exports = function (args, opts) {
70
70
var o = obj ;
71
71
for ( var i = 0 ; i < keys . length - 1 ; i ++ ) {
72
72
var key = keys [ i ] ;
73
- if ( key === '__proto__' ) return ;
73
+ if ( isConstructorOrProto ( o , key ) ) return ;
74
74
if ( o [ key ] === undefined ) o [ key ] = { } ;
75
75
if ( o [ key ] === Object . prototype || o [ key ] === Number . prototype
76
76
|| o [ key ] === String . prototype ) o [ key ] = { } ;
@@ -79,7 +79,7 @@ module.exports = function (args, opts) {
79
79
}
80
80
81
81
var key = keys [ keys . length - 1 ] ;
82
- if ( key === '__proto__' ) return ;
82
+ if ( isConstructorOrProto ( o , key ) ) return ;
83
83
if ( o === Object . prototype || o === Number . prototype
84
84
|| o === String . prototype ) o = { } ;
85
85
if ( o === Array . prototype ) o = [ ] ;
@@ -243,3 +243,7 @@ function isNumber (x) {
243
243
return / ^ [ - + ] ? (?: \d + (?: \. \d * ) ? | \. \d + ) ( e [ - + ] ? \d + ) ? $ / . test ( x ) ;
244
244
}
245
245
246
+
247
+ function isConstructorOrProto ( obj , key ) {
248
+ return key === 'constructor' && typeof obj [ key ] === 'function' || key === '__proto__' ;
249
+ }
You can’t perform that action at this time.
0 commit comments