We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 565f8a6 commit 0c1f978Copy full SHA for 0c1f978
src/lib/stringPath.ts
@@ -9,10 +9,10 @@ export function splitPath<T extends object>(path: string) {
9
10
export function mergePath(path: (string | number | symbol)[]) {
11
return path.reduce((acc: string, next) => {
12
- if (typeof next === 'number' || !isNaN(parseInt(String(next), 10)))
13
- acc += `[${String(next)}]`;
14
- else if (!acc) acc += String(next);
15
- else acc += `.${String(next)}`;
+ const key = String(next);
+ if (typeof next === 'number' || /^\d+$/.test(key)) acc += `[${key}]`;
+ else if (!acc) acc += key;
+ else acc += `.${key}`;
16
17
return acc;
18
}, '');
0 commit comments