mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Large blobs should be binary
This commit is contained in:
@@ -92,8 +92,22 @@ module Linguist
|
||||
#
|
||||
# Return true or false
|
||||
def binary?
|
||||
return false if data.empty?
|
||||
encoding.nil? || detect_encoding[:type] == :binary
|
||||
# Large blobs aren't even loaded into memory
|
||||
if data.nil?
|
||||
true
|
||||
|
||||
# Treat blank files as text
|
||||
elsif data == ""
|
||||
false
|
||||
|
||||
# Charlock doesn't know what to think
|
||||
elsif encoding.nil?
|
||||
true
|
||||
|
||||
# If Charlock says its binary
|
||||
else
|
||||
detect_encoding[:type] == :binary
|
||||
end
|
||||
end
|
||||
|
||||
# Public: Is the blob text?
|
||||
|
||||
Reference in New Issue
Block a user