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

Function parseKeyValue

source code/utils/git/gitConfigParser.ts:80–110  ·  view source on GitHub ↗

* Parse a key = value line. Returns null if the line doesn't contain a valid key.

(line: string)

Source from the content-addressed store, hash-verified

78 * Parse a key = value line. Returns null if the line doesn't contain a valid key.
79 */
80function parseKeyValue(line: string): { key: string; value: string } | null {
81 // Read key: alphanumeric + hyphen, starting with alpha
82 let i = 0
83 while (i < line.length && isKeyChar(line[i]!)) {
84 i++
85 }
86 if (i === 0) {
87 return null
88 }
89 const key = line.slice(0, i)
90
91 // Skip whitespace
92 while (i < line.length && (line[i] === ' ' || line[i] === '\t')) {
93 i++
94 }
95
96 // Must have '='
97 if (i >= line.length || line[i] !== '=') {
98 // Boolean key with no value — not relevant for our use cases
99 return null
100 }
101 i++ // skip '='
102
103 // Skip whitespace after '='
104 while (i < line.length && (line[i] === ' ' || line[i] === '\t')) {
105 i++
106 }
107
108 const value = parseValue(line, i)
109 return { key, value }
110}
111
112/**
113 * Parse a config value starting at position i.

Callers 1

parseConfigStringFunction · 0.85

Calls 2

isKeyCharFunction · 0.85
parseValueFunction · 0.85

Tested by

no test coverage detected