Skip to content

Commit

Permalink
only load blobs to check for <?php header for specific drupal file ex…
Browse files Browse the repository at this point in the history
…tensions
  • Loading branch information
tmm1 committed Nov 23, 2011
1 parent 21488c8 commit 9994ac3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/linguist/blob_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ def image?
['.png', '.jpg', '.jpeg', '.gif'].include?(extname)
end

# Public: Is the blob a possible drupal php file?
#
# Return true or false
def drupal_extname?
['.module', '.install', '.test', '.inc'].include?(extname)
end

MEGABYTE = 1024 * 1024

# Public: Is the blob too big to load?
Expand Down Expand Up @@ -512,10 +519,13 @@ def guess_gsp_language

# Internal: Guess language from the first line.
#
# Look for leading "<?php"
# Look for leading "<?php" in Drupal files
#
# Returns a Language.
def first_line_language
# Only check files with drupal php extensions
return unless drupal_extname?

# Fail fast if blob isn't viewable?
return unless viewable?

Expand Down

0 comments on commit 9994ac3

Please sign in to comment.