Make it safe to pass nil to Language.find_by_name/alias again

This restores compatibility with v3.4.x.
This commit is contained in:
Adam Roben
2014-11-10 15:12:29 -05:00
parent 32b07a4e10
commit 160598b9ef
2 changed files with 6 additions and 3 deletions

View File

@@ -164,7 +164,7 @@ module Linguist
#
# Returns the Language or nil if none was found.
def self.find_by_name(name)
@name_index[name.downcase]
name && @name_index[name.downcase]
end
# Public: Look up Language by one of its aliases.
@@ -178,7 +178,7 @@ module Linguist
#
# Returns the Lexer or nil if none was found.
def self.find_by_alias(name)
@alias_index[name.downcase]
name && @alias_index[name.downcase]
end
# Public: Look up Languages by filename.
@@ -243,7 +243,7 @@ module Linguist
#
# Returns the Language or nil if none was found.
def self.[](name)
@index[name.downcase]
name && @index[name.downcase]
end
# Public: A List of popular languages