normalizeOutput normalizes cross-platform differences for byte slice comparison: - Converts CRLF and CR to LF (line endings) - Converts backslashes to forward slashes (Windows paths) - Handles escaped backslashes in JSON (\\) by converting to single forward slash
(b []byte)
| 314 | // - Converts backslashes to forward slashes (Windows paths) |
| 315 | // - Handles escaped backslashes in JSON (\\) by converting to single forward slash |
| 316 | func normalizeOutput(b []byte) []byte { |
| 317 | b = bytes.ReplaceAll(b, []byte("\r\n"), []byte("\n")) |
| 318 | b = bytes.ReplaceAll(b, []byte("\r"), []byte("\n")) |
| 319 | // First replace escaped backslashes (common in JSON), then single backslashes |
| 320 | b = bytes.ReplaceAll(b, []byte("\\\\"), []byte("/")) |
| 321 | b = bytes.ReplaceAll(b, []byte("\\"), []byte("/")) |
| 322 | return b |
| 323 | } |
| 324 | |
| 325 | // normalizePathSeparators converts backslashes to forward slashes for cross-platform path comparison. |
| 326 | func normalizePathSeparators(s string) string { |
no outgoing calls
no test coverage detected
searching dependent graphs…