Skip to content

Commit 11e5dd5

Browse files
committed
add isValidKey function to ensure only valid keys are merged
1 parent 12cbc0b commit 11e5dd5

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ node_js:
1717
matrix:
1818
fast_finish: true
1919
allow_failures:
20+
- node_js: 'node'
2021
- node_js: '0.8'

index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module.exports = function mergeDeep(orig, objects) {
3232

3333
function merge(target, obj) {
3434
for (var key in obj) {
35-
if (key === '__proto__' || !hasOwn(obj, key)) {
35+
if (!isValidKey(key) || !hasOwn(obj, key)) {
3636
continue;
3737
}
3838

@@ -57,3 +57,7 @@ function hasOwn(obj, key) {
5757
function isObject(val) {
5858
return typeOf(val) === 'object' || typeOf(val) === 'function';
5959
}
60+
61+
function isValidKey(key) {
62+
return key !== '__proto__' && key !== 'constructor' && key !== 'prototype';
63+
}

0 commit comments

Comments
 (0)