MCPcopy Index your code
hub / github.com/anomalyco/opencode / unquoteGitPath

Function unquoteGitPath

packages/opencode/src/session/summary.ts:10–64  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

8import { Config } from "@/config/config"
9
10function unquoteGitPath(input: string) {
11 if (!input.startsWith('"')) return input
12 if (!input.endsWith('"')) return input
13 const body = input.slice(1, -1)
14 const bytes: number[] = []
15
16 for (let i = 0; i < body.length; i++) {
17 const char = body[i]!
18 if (char !== "\\") {
19 bytes.push(char.charCodeAt(0))
20 continue
21 }
22
23 const next = body[i + 1]
24 if (!next) {
25 bytes.push("\\".charCodeAt(0))
26 continue
27 }
28
29 if (next >= "0" && next <= "7") {
30 const chunk = body.slice(i + 1, i + 4)
31 const match = chunk.match(/^[0-7]{1,3}/)
32 if (!match) {
33 bytes.push(next.charCodeAt(0))
34 i++
35 continue
36 }
37 bytes.push(parseInt(match[0], 8))
38 i += match[0].length
39 continue
40 }
41
42 const escaped =
43 next === "n"
44 ? "\n"
45 : next === "r"
46 ? "\r"
47 : next === "t"
48 ? "\t"
49 : next === "b"
50 ? "\b"
51 : next === "f"
52 ? "\f"
53 : next === "v"
54 ? "\v"
55 : next === "\\" || next === '"'
56 ? next
57 : undefined
58
59 bytes.push((escaped ?? next).charCodeAt(0))
60 i++
61 }
62
63 return Buffer.from(bytes).toString()
64}
65
66export interface Interface {
67 readonly summarize: (input: { sessionID: SessionID; messageID: MessageID }) => Effect.Effect<void>

Callers 1

summary.tsFile · 0.70

Calls 2

pushMethod · 0.80
fromMethod · 0.45

Tested by

no test coverage detected