MCPcopy Create free account
hub / github.com/anomalyco/opencode / parseQuotedPath

Function parseQuotedPath

packages/opencode/src/project/vcs.ts:33–50  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

31const emptyBatch = () => ({ patches: new Map<string, string>(), capped: false })
32
33const parseQuotedPath = (value: string) => {
34 let out = ""
35 for (let idx = 1; idx < value.length; idx++) {
36 const char = value[idx]
37 if (char === '"') return { value: out, end: idx + 1 }
38 if (char !== "\\") {
39 out += char
40 continue
41 }
42
43 const next = value[++idx]
44 if (next === "t") out += "\t"
45 else if (next === "n") out += "\n"
46 else if (next === "r") out += "\r"
47 else if (next === '"' || next === "\\") out += next
48 else out += next ?? ""
49 }
50}
51
52const parsePathToken = (value: string) => {
53 if (!value.startsWith('"')) return value.split("\t")[0]

Callers 2

parsePathTokenFunction · 0.85
fileFromGitHeaderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected