From 52dff89530844d959cbd5f985660b877a1dc442a Mon Sep 17 00:00:00 2001
From: "(quasar) nebula" <qznebula@protonmail.com>
Date: Mon, 19 Feb 2024 14:01:16 -0400
Subject: sugar: splitKeys

---
 src/util/sugar.js | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'src')

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.
-- 
cgit 1.3.0-6-gf8a5