MCPcopy Create free account
hub / github.com/gogs/gogs / IsTextFile

Function IsTextFile

internal/tool/file.go:11–16  ·  view source on GitHub ↗

IsTextFile returns true if file content format is plain text or empty.

(data []byte)

Source from the content-addressed store, hash-verified

9
10// IsTextFile returns true if file content format is plain text or empty.
11func IsTextFile(data []byte) bool {
12 if len(data) == 0 {
13 return true
14 }
15 return strings.Contains(http.DetectContentType(data), "text/")
16}
17
18func IsImageFile(data []byte) bool {
19 return strings.Contains(http.DetectContentType(data), "image/")

Callers 5

renderNoticeBannerMethod · 0.92
serveDataFunction · 0.92
editFileFunction · 0.92
renderDirectoryFunction · 0.92
renderFileFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected