From 780cc2d11093e048e41f2d6da9d76f6c6ac4a5e2 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 30 Aug 2016 02:08:38 -0700 Subject: router/repo: code refactoring --- modules/base/tool.go | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'modules/base') diff --git a/modules/base/tool.go b/modules/base/tool.go index cf8fece027..e321d2b868 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -518,26 +518,14 @@ func IsLetter(ch rune) bool { return 'a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch == '_' || ch >= 0x80 && unicode.IsLetter(ch) } -func IsTextFile(data []byte) (string, bool) { - contentType := http.DetectContentType(data) - if strings.Index(contentType, "text/") != -1 { - return contentType, true - } - return contentType, false +func IsTextFile(data []byte) bool { + return strings.Index(http.DetectContentType(data), "text/") != -1 } -func IsImageFile(data []byte) (string, bool) { - contentType := http.DetectContentType(data) - if strings.Index(contentType, "image/") != -1 { - return contentType, true - } - return contentType, false +func IsImageFile(data []byte) bool { + return strings.Index(http.DetectContentType(data), "image/") != -1 } -func IsPDFFile(data []byte) (string, bool) { - contentType := http.DetectContentType(data) - if strings.Index(contentType, "application/pdf") != -1 { - return contentType, true - } - return contentType, false +func IsPDFFile(data []byte) bool { + return strings.Index(http.DetectContentType(data), "application/pdf") != -1 } -- cgit v1.2.3