mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-09-20 15:31:21 +00:00
Merge pull request #59 from mcarmonaa/fix/skip-binaries
binary files are returned as OtherLanguage by GetLanguage
This commit is contained in:
commit
317e70b972
@ -116,6 +116,10 @@ func GetLanguageBySpecificClassifier(content []byte, candidates []string, classi
|
|||||||
// GetLanguages applies a sequence of strategies based on the given filename and content
|
// GetLanguages applies a sequence of strategies based on the given filename and content
|
||||||
// to find out the most probably languages to return.
|
// to find out the most probably languages to return.
|
||||||
func GetLanguages(filename string, content []byte) []string {
|
func GetLanguages(filename string, content []byte) []string {
|
||||||
|
if IsBinary(content) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
var languages []string
|
var languages []string
|
||||||
candidates := []string{}
|
candidates := []string{}
|
||||||
for _, strategy := range DefaultStrategies {
|
for _, strategy := range DefaultStrategies {
|
||||||
|
@ -64,6 +64,7 @@ func (s *EnryTestSuite) TestGetLanguage() {
|
|||||||
{name: "TestGetLanguage_1", filename: "foo.py", content: []byte{}, expected: "Python"},
|
{name: "TestGetLanguage_1", filename: "foo.py", content: []byte{}, expected: "Python"},
|
||||||
{name: "TestGetLanguage_2", filename: "foo.m", content: []byte(":- module"), expected: "Mercury"},
|
{name: "TestGetLanguage_2", filename: "foo.m", content: []byte(":- module"), expected: "Mercury"},
|
||||||
{name: "TestGetLanguage_3", filename: "foo.m", content: nil, expected: OtherLanguage},
|
{name: "TestGetLanguage_3", filename: "foo.m", content: nil, expected: OtherLanguage},
|
||||||
|
{name: "TestGetLanguage_4", filename: "foo.mo", content: []byte{0xDE, 0x12, 0x04, 0x95, 0x00, 0x00, 0x00, 0x00}, expected: OtherLanguage},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
Loading…
Reference in New Issue
Block a user