Catching one more edge case

This commit is contained in:
Arfon Smith
2015-08-11 06:48:54 +01:00
parent 851c93a1f7
commit 997c0fca10
2 changed files with 2 additions and 0 deletions

View File

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

View File

@@ -278,6 +278,7 @@ class TestLanguage < Minitest::Test
def test_doesnt_blow_up_with_blank_lookup
assert_equal nil, Language.find_by_alias('')
assert_equal nil, Language.find_by_name(nil)
assert_equal nil, Language[""]
end
def test_name