Skip to content

Commit

Permalink
Ensure lang is skipped on any binary file
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Sep 24, 2012
1 parent 7c51b90 commit 31e33f9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/linguist/blob_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def language
if defined?(@data) && @data.is_a?(String)
data = @data
else
data = lambda { binary_mime_type? ? "" : self.data }
data = lambda { (binary_mime_type? || binary?) ? "" : self.data }
end

@language = Language.detect(name.to_s, data, mode)
Expand Down
4 changes: 3 additions & 1 deletion lib/linguist/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def self.detect(name, data, mode = nil)

if possible_languages.length > 1
data = data.call() if data.respond_to?(:call)
if result = Classifier.classify(Samples::DATA, data, possible_languages.map(&:name)).first
if data.nil? || data == ""
nil
elsif result = Classifier.classify(Samples::DATA, data, possible_languages.map(&:name)).first
Language[result[0]]
end
else
Expand Down

0 comments on commit 31e33f9

Please sign in to comment.