MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / NormalizeCommentIndentation

Function NormalizeCommentIndentation

internal/config/config.go:1309–1327  ·  view source on GitHub ↗

NormalizeCommentIndentation removes indentation from standalone YAML comment lines to keep them left aligned.

(data []byte)

Source from the content-addressed store, hash-verified

1307
1308// NormalizeCommentIndentation removes indentation from standalone YAML comment lines to keep them left aligned.
1309func NormalizeCommentIndentation(data []byte) []byte {
1310 lines := bytes.Split(data, []byte("\n"))
1311 changed := false
1312 for i, line := range lines {
1313 trimmed := bytes.TrimLeft(line, " \t")
1314 if len(trimmed) == 0 || trimmed[0] != '#' {
1315 continue
1316 }
1317 if len(trimmed) == len(line) {
1318 continue
1319 }
1320 lines[i] = append([]byte(nil), trimmed...)
1321 changed = true
1322 }
1323 if !changed {
1324 return data
1325 }
1326 return bytes.Join(lines, []byte("\n"))
1327}
1328
1329// getOrCreateMapValue finds the value node for a given key in a mapping node.
1330// If not found, it appends a new key/value pair and returns the new value node.

Calls

no outgoing calls

Tested by

no test coverage detected