summaryrefslogtreecommitdiffstats
path: root/modules/base/tool.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/base/tool.go')
-rw-r--r--modules/base/tool.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/modules/base/tool.go b/modules/base/tool.go
index e321d2b868..52d1e178db 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -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
}