summaryrefslogtreecommitdiff
path: root/src/edit/util.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-11-02 19:17:04 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-11-02 19:17:04 -0400
commitb51a2c03985f09845e498ece625f5e8a309b6086 (patch)
treeb592f25121cedb3ebaa83dea6cf2f953fceb4372 /src/edit/util.go
parent59294e30d099c6bddfa290278a8c0988a351606f (diff)
better MIME type detection
Diffstat (limited to 'src/edit/util.go')
-rw-r--r--src/edit/util.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/edit/util.go b/src/edit/util.go
index 566796c..b6dfde1 100644
--- a/src/edit/util.go
+++ b/src/edit/util.go
@@ -1,7 +1,10 @@
package main
import (
+ "mime"
+ "net/http"
"os/exec"
+ "path"
)
type exitError exec.ExitError
@@ -23,3 +26,11 @@ func errcheck(err error) {
panic(err)
}
}
+
+func getctype(name string, content []byte) string {
+ ctype := mime.TypeByExtension(path.Ext(name))
+ if ctype == "" {
+ ctype = http.DetectContentType(content)
+ }
+ return ctype
+}