MCPcopy Create free account
hub / github.com/MertJSX/folderhost / stripControlSequences

Function stripControlSequences

utils/service_utils/service_functions.go:73–89  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

71)
72
73func stripControlSequences(s string) string {
74 colors := ansiColorRegex.FindAllString(s, -1)
75 placeholders := make([]string, len(colors))
76 for i, c := range colors {
77 placeholders[i] = fmt.Sprintf("\x00COLOR%d\x00", i)
78 s = strings.Replace(s, c, placeholders[i], 1)
79 }
80
81 s = ansiEscapeRegex.ReplaceAllString(s, "")
82 s = strings.ReplaceAll(s, "\x1b", "")
83
84 for i, p := range placeholders {
85 s = strings.Replace(s, p, colors[i], 1)
86 }
87
88 return s
89}
90
91func (lb *LogBuffer) Write(p []byte) (n int, err error) {
92 lb.mu.Lock()

Callers 1

WriteMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected