Skip to content

Commit f14da89

Browse files
committed
refactor(stripJSONComments): reorder comment logic
1 parent f3b0e78 commit f14da89

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

cmd/mcp/mcp.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,17 @@ func stripJSONComments(data []byte) []byte {
136136
continue
137137
}
138138

139+
// Check multi-line comment first - skip all content including quotes
140+
if inMultiLineComment {
141+
if i+1 < len(content) && char == '*' && content[i+1] == '/' {
142+
inMultiLineComment = false
143+
i += 2
144+
continue
145+
}
146+
i++
147+
continue
148+
}
149+
139150
if char == '\\' && inString {
140151
escapeNext = true
141152
result.WriteByte(char)
@@ -156,16 +167,6 @@ func stripJSONComments(data []byte) []byte {
156167
continue
157168
}
158169

159-
if inMultiLineComment {
160-
if i+1 < len(content) && char == '*' && content[i+1] == '/' {
161-
inMultiLineComment = false
162-
i += 2
163-
continue
164-
}
165-
i++
166-
continue
167-
}
168-
169170
if i+1 < len(content) && char == '/' && content[i+1] == '/' {
170171
// Single-line comment - skip to end of line
171172
for i < len(content) && content[i] != '\n' {

0 commit comments

Comments
 (0)