fixed GetLanguageByContent returned value when there is not a function matcher for the extension

This commit is contained in:
Manuel Carmona 2017-04-28 12:35:09 +02:00
parent 28dc452853
commit 664afe48d4
3 changed files with 9 additions and 6 deletions

@ -14,10 +14,11 @@ func GetLanguageByContent(filename string, content []byte) (lang string, safe bo
ext := strings.ToLower(filepath.Ext(filename)) ext := strings.ToLower(filepath.Ext(filename))
if fnMatcher, ok := matchers[ext]; ok { if fnMatcher, ok := matchers[ext]; ok {
lang, safe = fnMatcher(content) lang, safe = fnMatcher(content)
return } else {
lang = OtherLanguage
} }
return GetLanguageByExtension(filename) return
} }
type languageMatcher func([]byte) (string, bool) type languageMatcher func([]byte) (string, bool)

@ -14,10 +14,11 @@ func GetLanguageByContent(filename string, content []byte) (lang string, safe bo
ext := strings.ToLower(filepath.Ext(filename)) ext := strings.ToLower(filepath.Ext(filename))
if fnMatcher, ok := matchers[ext]; ok { if fnMatcher, ok := matchers[ext]; ok {
lang, safe = fnMatcher(content) lang, safe = fnMatcher(content)
return } else {
lang = OtherLanguage
} }
return GetLanguageByExtension(filename) return
} }
type languageMatcher func ([]byte) (string, bool) type languageMatcher func ([]byte) (string, bool)

@ -14,10 +14,11 @@ func GetLanguageByContent(filename string, content []byte) (lang string, safe bo
ext := strings.ToLower(filepath.Ext(filename)) ext := strings.ToLower(filepath.Ext(filename))
if fnMatcher, ok := matchers[ext]; ok { if fnMatcher, ok := matchers[ext]; ok {
lang, safe = fnMatcher(content) lang, safe = fnMatcher(content)
return } else {
lang = OtherLanguage
} }
return GetLanguageByExtension(filename) return
} }
type languageMatcher func([]byte) (string, bool) type languageMatcher func([]byte) (string, bool)