MCPcopy
hub / github.com/docker/compose / stripAnsi

Function stripAnsi

cmd/display/tty_test.go:372–390  ·  cmd/display/tty_test.go::stripAnsi

stripAnsi removes ANSI escape codes from a string

(s string)

Source from the content-addressed store, hash-verified

370
371// stripAnsi removes ANSI escape codes from a string
372func stripAnsi(s string) string {
373 var result strings.Builder
374 inAnsi := false
375 for _, r := range s {
376 if r == '\x1b' {
377 inAnsi = true
378 continue
379 }
380 if inAnsi {
381 // ANSI sequences end with a letter (m, h, l, G, etc.)
382 if (r >= 'A' && r <= 'Z') || (r >= 'a' && r <= 'z') {
383 inAnsi = false
384 }
385 continue
386 }
387 result.WriteRune(r)
388 }
389 return result.String()
390}
391
392func TestPrintWithDimensions_PulledAndPullingWithLongIDs(t *testing.T) {
393 w, buf := newTestWriter()

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected