MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / staticString

Function staticString

src/resolution/frameworks/angular-router.ts:132–165  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

130 * links. Null when any part is computed.
131 */
132export function staticString(text: string): string | null {
133 const parts: string[] = [];
134 let rest = text.trim();
135 while (rest.length > 0) {
136 let part: string | null = null;
137 let used = 0;
138 const q = rest[0];
139 if (q === '"' || q === "'") {
140 part = readStringAt(rest, 0);
141 used = part === null ? 0 : skipString(rest, 0) + 1;
142 } else if (rest.startsWith('$localize')) {
143 const tick = rest.indexOf('`');
144 const end = tick < 0 ? -1 : skipString(rest, tick);
145 if (end > 0) {
146 part = localizeDefault(rest.slice(0, end + 1));
147 used = end + 1;
148 }
149 } else if (q === '`') {
150 const end = skipString(rest, 0);
151 const body = end > 0 ? rest.slice(1, end) : '';
152 if (end > 0 && !body.includes('${')) {
153 part = body;
154 used = end + 1;
155 }
156 }
157 if (part === null || used === 0) return null;
158 parts.push(part);
159 rest = rest.slice(used).trim();
160 if (rest.length === 0) break;
161 if (rest[0] !== '+') return null;
162 rest = rest.slice(1).trim();
163 }
164 return parts.length > 0 ? parts.join('') : null;
165}
166
167/** A route's own path segment(s): a string, a `$localize` default, or a constant kept as `{expr}`; null when it cannot be named. */
168function pathSegments(text: string): string[] | null {

Callers 8

componentsInFunction · 0.90
pathSegmentsFunction · 0.85
walkFunction · 0.85
constantValueFunction · 0.85
flushFunction · 0.85
commandsHrefFunction · 0.85
destinationOfFunction · 0.85

Calls 5

readStringAtFunction · 0.90
skipStringFunction · 0.90
localizeDefaultFunction · 0.85
pushMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected