MCPcopy
hub / github.com/go-task/task / normalizeOutput

Function normalizeOutput

task_test.go:316–323  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

314// - Converts backslashes to forward slashes (Windows paths)
315// - Handles escaped backslashes in JSON (\\) by converting to single forward slash
316func 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.
326func normalizePathSeparators(s string) string {

Callers 3

writeFixtureMethod · 0.85
NormalizedEqualFunction · 0.85
TestNormalizeOutputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…