MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / parseValue

Function parseValue

source code/utils/git/gitConfigParser.ts:116–186  ·  view source on GitHub ↗

* Parse a config value starting at position i. * Handles quoted strings, escape sequences, and inline comments.

(line: string, start: number)

Source from the content-addressed store, hash-verified

114 * Handles quoted strings, escape sequences, and inline comments.
115 */
116function parseValue(line: string, start: number): string {
117 let result = ''
118 let inQuote = false
119 let i = start
120
121 while (i < line.length) {
122 const ch = line[i]!
123
124 // Inline comments outside quotes end the value
125 if (!inQuote && (ch === '#' || ch === ';')) {
126 break
127 }
128
129 if (ch === '"') {
130 inQuote = !inQuote
131 i++
132 continue
133 }
134
135 if (ch === '\\' && i + 1 < line.length) {
136 const next = line[i + 1]!
137 if (inQuote) {
138 // Inside quotes: recognize escape sequences
139 switch (next) {
140 case 'n':
141 result += '\n'
142 break
143 case 't':
144 result += '\t'
145 break
146 case 'b':
147 result += '\b'
148 break
149 case '"':
150 result += '"'
151 break
152 case '\\':
153 result += '\\'
154 break
155 default:
156 // Git silently drops the backslash for unknown escapes
157 result += next
158 break
159 }
160 i += 2
161 continue
162 }
163 // Outside quotes: backslash at end of line = continuation (we don't
164 // handle multi-line since we split on \n, but handle \\ and others)
165 if (next === '\\') {
166 result += '\\'
167 i += 2
168 continue
169 }
170 // Fallthrough — treat backslash literally outside quotes
171 }
172
173 result += ch

Callers 1

parseKeyValueFunction · 0.85

Calls 1

trimTrailingWhitespaceFunction · 0.85

Tested by

no test coverage detected