mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-05-23 00:20:09 -03:00
common: Return nil on empty filenames
Signed-off-by: Alfredo Beaumont <alfredo.beaumont@gmail.com>
This commit is contained in:
parent
a7cfa65953
commit
c590beb039
@ -266,6 +266,10 @@ func GetLanguagesByVimModeline(_ string, content []byte, _ []string) []string {
|
||||
// GetLanguagesByFilename returns a slice of possible languages for the given filename.
|
||||
// It complies with the signature to be a Strategy type.
|
||||
func GetLanguagesByFilename(filename string, _ []byte, _ []string) []string {
|
||||
if filename == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
return data.LanguagesByFilename[filepath.Base(filename)]
|
||||
}
|
||||
|
||||
@ -385,6 +389,10 @@ func getDotIndexes(filename string) []int {
|
||||
// GetLanguagesByContent returns a slice of possible languages for the given content.
|
||||
// It complies with the signature to be a Strategy type.
|
||||
func GetLanguagesByContent(filename string, content []byte, _ []string) []string {
|
||||
if filename == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
ext := strings.ToLower(filepath.Ext(filename))
|
||||
fnMatcher, ok := data.ContentMatchers[ext]
|
||||
if !ok {
|
||||
|
Loading…
x
Reference in New Issue
Block a user