diff options
author | FuXiaoHei <fuxiaohei@hexiaz.com> | 2014-03-25 00:02:37 +0800 |
---|---|---|
committer | FuXiaoHei <fuxiaohei@hexiaz.com> | 2014-03-25 00:02:37 +0800 |
commit | 8909935a1049dea3783021f0460118ad838b1dfd (patch) | |
tree | 00d23ec41174cda54d5bf2de1175a9d635b75f9a /modules/base/markdown.go | |
parent | 62b05c1e228f1a570a97e6957c45e018262f812f (diff) | |
parent | 6302f5462890b455cb306fc3925c71850a6e1dfb (diff) |
Merge branch 'master' of https://github.com/gogits/gogs
Diffstat (limited to 'modules/base/markdown.go')
-rw-r--r-- | modules/base/markdown.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/modules/base/markdown.go b/modules/base/markdown.go index 05ce0c83..c722f04b 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -6,6 +6,7 @@ package base import ( "bytes" + "net/http" "path" "path/filepath" "strings" @@ -42,6 +43,14 @@ func IsMarkdownFile(name string) bool { return false } +func IsTextFile(data []byte) (string, bool) { + contentType := http.DetectContentType(data) + if strings.Index(contentType, "text/") != -1 { + return contentType, true + } + return contentType, false +} + func IsReadmeFile(name string) bool { name = strings.ToLower(name) if len(name) < 6 { |