From 720d2ce9b2d6962d3d0a7b93740096b98cce1e40 Mon Sep 17 00:00:00 2001 From: Gabriel Felipe Date: Wed, 10 Jun 2020 16:01:45 -0300 Subject: [PATCH] Ignore paths that not exists When using the "pick" method when making parsePath and the specified path does not exist, an error occurs where it is not possible to make the indexOf of undefined --- src/dot-object.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/dot-object.js b/src/dot-object.js index 6a3a0e5..b1a7135 100644 --- a/src/dot-object.js +++ b/src/dot-object.js @@ -49,6 +49,9 @@ var blacklist = ['__proto__', 'prototype', 'constructor'] var blacklistFilter = function (part) { return blacklist.indexOf(part) === -1 } function parsePath (path, sep) { + if (!path) { + return []; + } if (path.indexOf('[') >= 0) { path = path.replace(/\[/g, '.').replace(/]/g, '') }