Don't blow up if empty string/nil passed to alias methods

This commit is contained in:
Arfon Smith
2015-08-10 22:07:28 +01:00
parent a5f7355e16
commit 851c93a1f7
2 changed files with 7 additions and 0 deletions

View File

@@ -150,6 +150,7 @@ module Linguist
#
# Returns the Language or nil if none was found.
def self.find_by_name(name)
return nil if name.to_s.empty?
name && (@name_index[name.downcase] || @name_index[name.split(',').first.downcase])
end
@@ -164,6 +165,7 @@ module Linguist
#
# Returns the Language or nil if none was found.
def self.find_by_alias(name)
return nil if name.to_s.empty?
name && (@alias_index[name.downcase] || @alias_index[name.split(',').first.downcase])
end