(segment: string)
| 208 | } |
| 209 | |
| 210 | function tokenize(segment: string): string[] { |
| 211 | const tokens: string[] = []; |
| 212 | let current = ''; |
| 213 | let quote: '"' | "'" | null = null; |
| 214 | for (let i = 0; i < segment.length; i += 1) { |
| 215 | const ch = segment.charAt(i); |
| 216 | if ((ch === '"' || ch === "'") && !isEscapedQuote(segment, i)) { |
| 217 | quote = updateQuoteState(quote, ch); |
| 218 | current += ch; |
| 219 | continue; |
| 220 | } |
| 221 | if (!quote && /\s/.test(ch)) { |
| 222 | if (current.trim()) tokens.push(current.trim()); |
| 223 | current = ''; |
| 224 | continue; |
| 225 | } |
| 226 | current += ch; |
| 227 | } |
| 228 | if (quote) { |
| 229 | throw new AppError('INVALID_ARGS', `Unclosed quote in selector: ${segment}`); |
| 230 | } |
| 231 | if (current.trim()) tokens.push(current.trim()); |
| 232 | return tokens; |
| 233 | } |
| 234 | |
| 235 | function updateQuoteState(currentQuote: '"' | "'" | null, ch: '"' | "'"): '"' | "'" | null { |
| 236 | if (!currentQuote) return ch; |
no test coverage detected
searching dependent graphs…