mirror of
https://github.com/KevinMidboe/linguist.git
synced 2026-01-23 17:55:32 +00:00
Place guards, checks for multiline shell hacks
This commit is contained in:
@@ -110,10 +110,10 @@ module Linguist
|
||||
data = data.call() if data.respond_to?(:call)
|
||||
if data.nil? || data == ""
|
||||
nil
|
||||
elsif result = find_by_shebang(data)
|
||||
elsif (result = find_by_shebang(data)) && !result.empty?
|
||||
result.first
|
||||
elsif result = Classifier.classify(Samples::DATA, data, possible_languages.map(&:name)).first
|
||||
Language[result[0]]
|
||||
elsif classified = Classifier.classify(Samples::DATA, data, possible_languages.map(&:name)).first
|
||||
Language[classified[0]]
|
||||
end
|
||||
else
|
||||
possible_languages.first
|
||||
|
||||
Reference in New Issue
Block a user