(input: string)
| 36 | } |
| 37 | |
| 38 | function scanHeaderToken(input: string): { token: string; rest: string } | null { |
| 39 | const trimmed = input.trimStart(); |
| 40 | if (!trimmed) return null; |
| 41 | |
| 42 | if (trimmed.startsWith('"')) { |
| 43 | let escaped = false; |
| 44 | for (let i = 1; i < trimmed.length; i += 1) { |
| 45 | const char = trimmed[i]; |
| 46 | if (escaped) { |
| 47 | escaped = false; |
| 48 | continue; |
| 49 | } |
| 50 | if (char === "\\") { |
| 51 | escaped = true; |
| 52 | continue; |
| 53 | } |
| 54 | if (char === '"') { |
| 55 | return { token: trimmed.slice(0, i + 1), rest: trimmed.slice(i + 1) }; |
| 56 | } |
| 57 | } |
| 58 | return null; |
| 59 | } |
| 60 | |
| 61 | const space = trimmed.indexOf(" "); |
| 62 | if (space === -1) return { token: trimmed, rest: "" }; |
| 63 | return { token: trimmed.slice(0, space), rest: trimmed.slice(space + 1) }; |
| 64 | } |
| 65 | |
| 66 | export function parseDiffGitHeader(header: string): DiffPathPair { |
| 67 | const prefix = "diff --git "; |
no outgoing calls
no test coverage detected