MCPcopy Index your code
hub / github.com/codeaashu/claude-code / parseKeyValue

Function parseKeyValue

src/utils/git/gitConfigParser.ts:78–108  ·  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

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