summaryrefslogtreecommitdiff
path: root/node_modules/tailwindcss/lib/util/toPath.js
diff options
context:
space:
mode:
authorPhilipp Tanlak <philipp.tanlak@gmail.com>2025-11-24 20:54:57 +0100
committerPhilipp Tanlak <philipp.tanlak@gmail.com>2025-11-24 20:57:48 +0100
commitb1e2c8fd5cb5dfa46bc440a12eafaf56cd844b1c (patch)
tree49d360fd6cbc6a2754efe93524ac47ff0fbe0f7d /node_modules/tailwindcss/lib/util/toPath.js
Docs
Diffstat (limited to 'node_modules/tailwindcss/lib/util/toPath.js')
-rw-r--r--node_modules/tailwindcss/lib/util/toPath.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/node_modules/tailwindcss/lib/util/toPath.js b/node_modules/tailwindcss/lib/util/toPath.js
new file mode 100644
index 0000000..ef4fd8b
--- /dev/null
+++ b/node_modules/tailwindcss/lib/util/toPath.js
@@ -0,0 +1,32 @@
+/**
+ * Parse a path string into an array of path segments.
+ *
+ * Square bracket notation `a[b]` may be used to "escape" dots that would otherwise be interpreted as path separators.
+ *
+ * Example:
+ * a -> ['a']
+ * a.b.c -> ['a', 'b', 'c']
+ * a[b].c -> ['a', 'b', 'c']
+ * a[b.c].e.f -> ['a', 'b.c', 'e', 'f']
+ * a[b][c][d] -> ['a', 'b', 'c', 'd']
+ *
+ * @param {string|string[]} path
+ **/ "use strict";
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+Object.defineProperty(exports, "toPath", {
+ enumerable: true,
+ get: function() {
+ return toPath;
+ }
+});
+function toPath(path) {
+ if (Array.isArray(path)) return path;
+ let openBrackets = path.split("[").length - 1;
+ let closedBrackets = path.split("]").length - 1;
+ if (openBrackets !== closedBrackets) {
+ throw new Error(`Path is invalid. Has unbalanced brackets: ${path}`);
+ }
+ return path.split(/\.(?![^\[]*\])|[\[\]]/g).filter(Boolean);
+}