diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/sugar.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/util/sugar.js b/src/util/sugar.js index 3c364ee5..e060f458 100644 --- a/src/util/sugar.js +++ b/src/util/sugar.js @@ -268,6 +268,10 @@ export function escapeRegex(string) { return string.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'); } +export function splitKeys(key) { + return key.split(/(?<=(?<!\\)(?:\\\\)*)\./); +} + // Follows a key path like 'foo.bar.baz' to get an item nested deeply inside // an object. export function getNestedProp(obj, key) { @@ -276,7 +280,7 @@ export function getNestedProp(obj, key) { ? o[k[0]] : recursive(o[k[0]], k.slice(1))); - return recursive(obj, key.split(/(?<=(?<!\\)(?:\\\\)*)\./)); + return recursive(obj, splitKeys(key)); } // Gets the "look" of some arbitrary value. It's like typeof, but smarter. |