fixed GetLanguageByContent returned value when there is not a function matcher for the extension
This commit is contained in:
parent
28dc452853
commit
664afe48d4
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user