MCPcopy Create free account
hub / github.com/backnotprop/plannotator / scanHeaderToken

Function scanHeaderToken

packages/shared/diff-paths.ts:38–64  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

36}
37
38function 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
66export function parseDiffGitHeader(header: string): DiffPathPair {
67 const prefix = "diff --git ";

Callers 1

parseDiffGitHeaderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected