(line: string)
| 11 | * Inside double quotes, `\"` and `\\` are escapes. Single-quoted text is literal (no escapes). |
| 12 | * Adjacent quoted and unquoted segments form one word (e.g. `ab"c d"` → `abc d`). |
| 13 | */ |
| 14 | export function splitQuotedLine(line: string): string[] { |
| 15 | const result: string[] = []; |
| 16 | let current = ''; |
| 17 | let inQuote: false | '"' | "'" = false; |
| 18 | let i = 0; |
| 19 | |
| 20 | while (i < line.length && (line[i] === ' ' || line[i] === '\t')) { |
| 21 | i++; |
| 22 | } |
| 23 | |
| 24 | while (i < line.length) { |
| 25 | const c = line[i]; |
| 26 | if (inQuote === '"') { |
| 27 | if (c === '\\' && i + 1 < line.length && (line[i + 1] === '"' || line[i + 1] === '\\')) { |
| 28 | current += line[i + 1]; |
| 29 | i += 2; |
| 30 | continue; |
| 31 | } |
| 32 | if (c === '"') { |
| 33 | inQuote = false; |
| 34 | i++; |
| 35 | continue; |
| 36 | } |
| 37 | current += c; |
| 38 | i++; |
| 39 | continue; |
| 40 | } |
| 41 | if (inQuote === "'") { |
| 42 | if (c === "'") { |
| 43 | inQuote = false; |
| 44 | i++; |
| 45 | continue; |
| 46 | } |
| 47 | current += c; |
| 48 | i++; |
| 49 | continue; |
| 50 | } |
| 51 | if (c === '"') { |
| 52 | inQuote = '"'; |
| 53 | i++; |
| 54 | continue; |
| 55 | } |
| 56 | if (c === "'") { |
| 57 | inQuote = "'"; |
| 58 | i++; |
| 59 | continue; |
| 60 | } |
| 61 | if (c === ' ' || c === '\t') { |
| 62 | result.push(current); |
| 63 | current = ''; |
| 64 | i++; |
| 65 | while (i < line.length && (line[i] === ' ' || line[i] === '\t')) { |
| 66 | i++; |
no outgoing calls
no test coverage detected