mirror of
https://github.com/jc21/nginx-proxy-manager.git
synced 2024-08-30 18:22:48 +00:00
- Added upstream objects
- Renamed host templates to nginx templates - Generate upstream templates - Better nginx error reporting when reloading - Use tparse for golang test reporting
This commit is contained in:
24
backend/internal/util/strings.go
Normal file
24
backend/internal/util/strings.go
Normal file
@ -0,0 +1,24 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
// CleanupWhitespace will trim up and remove extra lines and stuff
|
||||
func CleanupWhitespace(s string) string {
|
||||
// Remove trailing whitespace from all lines
|
||||
slices := strings.Split(s, "\n")
|
||||
for idx := range slices {
|
||||
slices[idx] = strings.TrimRightFunc(slices[idx], unicode.IsSpace)
|
||||
}
|
||||
// Output: [a b c]
|
||||
result := strings.Join(slices, "\n")
|
||||
|
||||
// Remove empty lines
|
||||
r1 := regexp.MustCompile("\n+")
|
||||
result = r1.ReplaceAllString(result, "\n")
|
||||
|
||||
return result
|
||||
}
|
Reference in New Issue
Block a user