mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	Allow for split(",") returning nil (#3424)
This commit is contained in:
		| @@ -215,7 +215,14 @@ 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]) | ||||
|  | ||||
|       lang = @index[name.downcase] | ||||
|       return lang if lang | ||||
|  | ||||
|       name = name.split(',').first | ||||
|       return nil if name.to_s.empty? | ||||
|  | ||||
|       @index[name.downcase] | ||||
|     end | ||||
|  | ||||
|     # Public: A List of popular languages | ||||
|   | ||||
| @@ -460,4 +460,8 @@ class TestLanguage < Minitest::Test | ||||
|       assert !language.color, "Unused colour assigned to #{language.name}" | ||||
|     end | ||||
|   end | ||||
|  | ||||
|   def test_non_crash_on_comma | ||||
|     assert_nil Language[','] | ||||
|   end | ||||
| end | ||||
|   | ||||
		Reference in New Issue
	
	Block a user