1
0
Fork 0
forked from forgejo/forgejo

#3559 fix template error

This commit is contained in:
Unknwon 2016-08-31 13:59:23 -07:00
parent c2afdf2192
commit dadd35b636
5 changed files with 10 additions and 11 deletions

View file

@ -518,7 +518,11 @@ func IsLetter(ch rune) bool {
return 'a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch == '_' || ch >= 0x80 && unicode.IsLetter(ch)
}
// IsTextFile returns true if file content format is plain text or empty.
func IsTextFile(data []byte) bool {
if len(data) == 0 {
return true
}
return strings.Index(http.DetectContentType(data), "text/") != -1
}