mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-05-23 16:40:08 -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.
|
// GetLanguagesByFilename returns a slice of possible languages for the given filename.
|
||||||
// It complies with the signature to be a Strategy type.
|
// It complies with the signature to be a Strategy type.
|
||||||
func GetLanguagesByFilename(filename string, _ []byte, _ []string) []string {
|
func GetLanguagesByFilename(filename string, _ []byte, _ []string) []string {
|
||||||
|
if filename == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
return data.LanguagesByFilename[filepath.Base(filename)]
|
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.
|
// GetLanguagesByContent returns a slice of possible languages for the given content.
|
||||||
// It complies with the signature to be a Strategy type.
|
// It complies with the signature to be a Strategy type.
|
||||||
func GetLanguagesByContent(filename string, content []byte, _ []string) []string {
|
func GetLanguagesByContent(filename string, content []byte, _ []string) []string {
|
||||||
|
if filename == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
ext := strings.ToLower(filepath.Ext(filename))
|
ext := strings.ToLower(filepath.Ext(filename))
|
||||||
fnMatcher, ok := data.ContentMatchers[ext]
|
fnMatcher, ok := data.ContentMatchers[ext]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user