MCPcopy Create free account
hub / github.com/decaporg/decap-cms / keyToPathArray

Function keyToPathArray

packages/decap-cms-lib-widgets/src/stringTemplate.ts:84–108  ·  view source on GitHub ↗
(key?: string)

Source from the content-addressed store, hash-verified

82export const SLUG_MISSING_REQUIRED_DATE = 'SLUG_MISSING_REQUIRED_DATE';
83
84export function keyToPathArray(key?: string) {
85 if (!key) {
86 return [];
87 }
88 const parts = [];
89 const separator = '';
90 const chars = key.split(separator);
91
92 let currentChar;
93 let currentStr = [];
94 while ((currentChar = chars.shift())) {
95 if (['[', ']', '.'].includes(currentChar)) {
96 if (currentStr.length > 0) {
97 parts.push(currentStr.join(separator));
98 }
99 currentStr = [];
100 } else {
101 currentStr.push(currentChar);
102 }
103 }
104 if (currentStr.length > 0) {
105 parts.push(currentStr.join(separator));
106 }
107 return parts;
108}
109
110export function expandPath({
111 data,

Callers 10

compileStringTemplateFunction · 0.85
selectEntriesFunction · 0.85
getGroupFunction · 0.85
selectFieldFunction · 0.85
slugFormatterFunction · 0.85
summaryFormatterFunction · 0.85
folderFormatterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected