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

Function staticString

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

Source from the content-addressed store, hash-verified

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