mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
bail fast on file extensions we recognize as binary
This commit is contained in:
@@ -90,6 +90,15 @@ module Linguist
|
|||||||
@detect_encoding ||= CharlockHolmes::EncodingDetector.new.detect(data) if data
|
@detect_encoding ||= CharlockHolmes::EncodingDetector.new.detect(data) if data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Public: Is the blob binary according to its mime type
|
||||||
|
#
|
||||||
|
# Return true or false
|
||||||
|
def binary_mime_type?
|
||||||
|
if mime_type = Mime.lookup_mime_type_for(pathname.extname)
|
||||||
|
mime_type.binary?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Public: Is the blob binary?
|
# Public: Is the blob binary?
|
||||||
#
|
#
|
||||||
# Return true or false
|
# Return true or false
|
||||||
|
|||||||
@@ -67,6 +67,9 @@ module Linguist
|
|||||||
return if @computed_stats
|
return if @computed_stats
|
||||||
|
|
||||||
@enum.each do |blob|
|
@enum.each do |blob|
|
||||||
|
# Skip binary file extensions
|
||||||
|
next if blob.binary_mime_type?
|
||||||
|
|
||||||
# Skip vendored or generated blobs
|
# Skip vendored or generated blobs
|
||||||
next if blob.vendored? || blob.generated? || blob.language.nil?
|
next if blob.vendored? || blob.generated? || blob.language.nil?
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user