diff options
author | Unknwon <u@gogs.io> | 2016-08-30 02:08:38 -0700 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-08-30 02:08:38 -0700 |
commit | 780cc2d11093e048e41f2d6da9d76f6c6ac4a5e2 (patch) | |
tree | 1657d9fecdcf70d4e0067724344f531d608efb71 /modules/base | |
parent | 2a13f682e0fa039a610e7817495d87685f9632f2 (diff) | |
download | gitea-780cc2d11093e048e41f2d6da9d76f6c6ac4a5e2.tar.gz gitea-780cc2d11093e048e41f2d6da9d76f6c6ac4a5e2.zip |
router/repo: code refactoring
Diffstat (limited to 'modules/base')
-rw-r--r-- | modules/base/tool.go | 24 |
1 files changed, 6 insertions, 18 deletions
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 } |