MCPcopy Index your code
hub / github.com/callstack/agent-device / splitByFallback

Function splitByFallback

src/utils/selectors-parse.ts:179–208  ·  view source on GitHub ↗
(expression: string)

Source from the content-addressed store, hash-verified

177}
178
179function splitByFallback(expression: string): string[] {
180 const segments: string[] = [];
181 let current = '';
182 let quote: '"' | "'" | null = null;
183 for (let i = 0; i < expression.length; i += 1) {
184 const ch = expression[i];
185 if ((ch === '"' || ch === "'") && !isEscapedQuote(expression, i)) {
186 quote = updateQuoteState(quote, ch);
187 current += ch;
188 continue;
189 }
190 if (!quote && ch === '|' && expression[i + 1] === '|') {
191 const segment = current.trim();
192 if (!segment) {
193 throw new AppError('INVALID_ARGS', `Invalid selector fallback expression: ${expression}`);
194 }
195 segments.push(segment);
196 current = '';
197 i += 1;
198 continue;
199 }
200 current += ch;
201 }
202 const finalSegment = current.trim();
203 if (!finalSegment) {
204 throw new AppError('INVALID_ARGS', `Invalid selector fallback expression: ${expression}`);
205 }
206 segments.push(finalSegment);
207 return segments;
208}
209
210function tokenize(segment: string): string[] {
211 const tokens: string[] = [];

Callers 1

parseSelectorChainFunction · 0.85

Calls 3

isEscapedQuoteFunction · 0.85
updateQuoteStateFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…