MCPcopy Index your code
hub / github.com/git-bug/git-bug / Cleanup

Function Cleanup

util/text/transform.go:11–33  ·  view source on GitHub ↗
(text string)

Source from the content-addressed store, hash-verified

9)
10
11func Cleanup(text string) string {
12 // windows new line, Github, really ?
13 text = strings.Replace(text, "\r\n", "\n", -1)
14
15 // remove all unicode control characters except
16 // '\n', '\r' and '\t'
17 t := runes.Remove(runes.Predicate(func(r rune) bool {
18 switch r {
19 case '\r', '\n', '\t':
20 return false
21 }
22 return unicode.IsControl(r)
23 }))
24 sanitized, _, err := transform.String(t, text)
25 if err != nil {
26 // transform.String should never return an error as our transformer doesn't returns one.
27 // Confirmed with fuzzing.
28 panic(err)
29 }
30
31 // trim extra new line not displayed in the github UI but still present in the data
32 return strings.TrimSpace(sanitized)
33}
34
35func CleanupOneLine(text string) string {
36 // remove all unicode control characters *including*

Callers 15

ensureIssueMethod · 0.92
ensureCommentEditMethod · 0.92
ensureCommentMethod · 0.92
ImportAllMethod · 0.92
ensureIssueMethod · 0.92
ensureIssueEventMethod · 0.92
ensureIssueMethod · 0.92
ensureCommentMethod · 0.92
ensureChangeMethod · 0.92
runBugNewFunction · 0.92
runBugCommentNewFunction · 0.92
BugCreateMethod · 0.92

Calls 2

RemoveMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected