<commit_before>package operation

import (
	"bytes"
	"compress/flate"
	"compress/gzip"
	"io/ioutil"
	"strings"

	"github.com/chrislusf/seaweedfs/weed/glog"
	"golang.org/x/tools/godoc/util"
)

/*
* Default more not to gzip since gzip can be done on client side.
 */
func IsGzippable(ext, mtype string, data []byte) bool {

	// text
	if strings.HasPrefix(mtype, "text/") {
		return true
	}

	// images
	switch ext {
	case ".svg", ".bmp":
		return true
	}
	if strings.HasPrefix(mtype, "image/") {
		return false
	}

	// by file name extention
	switch ext {
	case ".zip", ".rar", ".gz", ".bz2", ".xz":
		return false
	case ".pdf", ".txt", ".html", ".htm", ".css", ".js", ".json":
		return true
	case ".php", ".java", ".go", ".rb", ".c", ".cpp", ".h", ".hpp":
		return true
	case ".png", ".jpg", ".jpeg", "":
		return true
	}
<commit_msg>avoid gzipping files without file extensions<commit_after>package operation

import (
	"bytes"
	"compress/flate"
	"compress/gzip"
	"io/ioutil"
	"strings"

	"github.com/chrislusf/seaweedfs/weed/glog"
	"golang.org/x/tools/godoc/util"
)

/*
* Default more not to gzip since gzip can be done on client side.
 */
func IsGzippable(ext, mtype string, data []byte) bool {

	// text
	if strings.HasPrefix(mtype, "text/") {
		return true
	}

	// images
	switch ext {
	case ".svg", ".bmp":
		return true
	}
	if strings.HasPrefix(mtype, "image/") {
		return false
	}

	// by file name extention
	switch ext {
	case ".zip", ".rar", ".gz", ".bz2", ".xz":
		return false
	case ".pdf", ".txt", ".html", ".htm", ".css", ".js", ".json":
		return true
	case ".php", ".java", ".go", ".rb", ".c", ".cpp", ".h", ".hpp":
		return true
	case ".png", ".jpg", ".jpeg":
		return false
	}

{'fraction_non_alphanumeric': 0.20602125147579692, 'fraction_numerical': 0.0011806375442739079, 'mean_word_length': 3.124087591240876, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2331006', 'n_tokens_mistral': 695, 'n_tokens_neox': 655, 'n_words': 185}