Add entity filters back in for api

This commit is contained in:
Jamie Curnow
2023-05-29 13:53:16 +10:00
parent 1ae247b2a6
commit 4b39ef0eba
20 changed files with 247 additions and 205 deletions

View File

@ -1,6 +1,9 @@
package util
import (
"bytes"
"encoding/json"
"npm/internal/logger"
"regexp"
"strings"
"unicode"
@ -22,3 +25,16 @@ func CleanupWhitespace(s string) string {
return result
}
// PrettyPrintJSON takes a string and as long as it's JSON,
// it will return a pretty printed and formatted version
func PrettyPrintJSON(s string) string {
byt := []byte(s)
var prettyJSON bytes.Buffer
if err := json.Indent(&prettyJSON, byt, "", " "); err != nil {
logger.Debug("Can't pretty print non-json string: %s", s)
return s
}
return prettyJSON.String()
}