support.go 579 B

123456789101112131415161718192021222324252627
  1. package builder
  2. import (
  3. "regexp"
  4. "strings"
  5. )
  6. const acceptableRemoteMIME = `(?:application/(?:(?:x\-)?tar|octet\-stream|((?:x\-)?(?:gzip|bzip2?|xz)))|(?:text/plain))`
  7. var mimeRe = regexp.MustCompile(acceptableRemoteMIME)
  8. func selectAcceptableMIME(ct string) string {
  9. return mimeRe.FindString(ct)
  10. }
  11. func handleJsonArgs(args []string, attributes map[string]bool) []string {
  12. if len(args) == 0 {
  13. return []string{}
  14. }
  15. if attributes != nil && attributes["json"] {
  16. return args
  17. }
  18. // literal string command, not an exec array
  19. return []string{strings.Join(args, " ")}
  20. }