diff options
Diffstat (limited to 'src/edit/util.go')
-rw-r--r-- | src/edit/util.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/edit/util.go b/src/edit/util.go index b6dfde1..5835b10 100644 --- a/src/edit/util.go +++ b/src/edit/util.go @@ -5,6 +5,7 @@ import ( "net/http" "os/exec" "path" + "strings" ) type exitError exec.ExitError @@ -34,3 +35,13 @@ func getctype(name string, content []byte) string { } return ctype } + +func istext(ctype string) bool { + i := strings.Index(ctype, ";") + if i == -1 { + i = len(ctype) + } + ctype = strings.TrimSpace(strings.ToLower(ctype[0:i])) + + return strings.HasPrefix(ctype, "text/") || strings.HasSuffix(ctype, "+xml") +} |