MCPcopy
hub / github.com/directus/directus / splitFieldPath

Function splitFieldPath

api/src/utils/split-field-path.ts:13–29  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

11 * splitFieldPath('a.json(meta, x.y.z)') // ['a', 'json(meta, x.y.z)']
12 */
13export function splitFieldPath(path: string): string[] {
14 const parts: string[] = [];
15 let depth = 0;
16 let start = 0;
17
18 for (let i = 0; i < path.length; i++) {
19 if (path[i] === '(') depth++;
20 else if (path[i] === ')') depth--;
21 else if (path[i] === '.' && depth === 0) {
22 parts.push(path.slice(start, i));
23 start = i + 1;
24 }
25 }
26
27 parts.push(path.slice(start));
28 return parts;
29}

Callers 4

getDBQueryFunction · 0.85
applySortFunction · 0.85
parseFieldsFunction · 0.85

Calls 1

sliceMethod · 0.80

Tested by

no test coverage detected