Comparing version 5.1.0 to 5.1.1
@@ -26,4 +26,8 @@ declare const dotProp: { | ||
object: {[key: string]: any}, | ||
path: string | ||
): T | undefined; | ||
get<T>( | ||
object: {[key: string]: any}, | ||
path: string, | ||
defaultValue?: T | ||
defaultValue: T | ||
): T; | ||
@@ -30,0 +34,0 @@ |
18
index.js
'use strict'; | ||
const isObj = require('is-obj'); | ||
const disallowedKeys = [ | ||
'__proto__', | ||
'prototype', | ||
'constructor' | ||
]; | ||
const isValidPath = pathSegments => !pathSegments.some(segment => disallowedKeys.includes(segment)); | ||
function getPathSegments(path) { | ||
@@ -19,2 +27,6 @@ const pathArray = path.split('.'); | ||
if (!isValidPath(parts)) { | ||
return []; | ||
} | ||
return parts; | ||
@@ -30,2 +42,5 @@ } | ||
const pathArray = getPathSegments(path); | ||
if (pathArray.length === 0) { | ||
return; | ||
} | ||
@@ -110,2 +125,5 @@ for (let i = 0; i < pathArray.length; i++) { | ||
const pathArray = getPathSegments(path); | ||
if (pathArray.length === 0) { | ||
return false; | ||
} | ||
@@ -112,0 +130,0 @@ for (let i = 0; i < pathArray.length; i++) { |
{ | ||
"name": "dot-prop", | ||
"version": "5.1.0", | ||
"version": "5.1.1", | ||
"description": "Get, set, or delete a property from a nested object using a dot path", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -88,2 +88,4 @@ # dot-prop [![Build Status](https://travis-ci.org/sindresorhus/dot-prop.svg?branch=master)](https://travis-ci.org/sindresorhus/dot-prop) | ||
The following path components are invalid and results in `undefined` being returned: `__proto__`, `prototype`, `constructor`. | ||
#### value | ||
@@ -90,0 +92,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9244
189
114