Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Commit

Permalink
Avoid regexp literals
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Jun 7, 2011
1 parent 64fe8b0 commit 72a43b6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/sprockets/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ def evaluate(filename, options = {})
data = data.sub(utf8_bom_re, '')
end
else
utf8_bom_re = /\A\xEF\xBB\xBF/
utf8_bom_re = Regexp.new("\\A\\xEF\\xBB\\xBF")

if data =~ utf8_bom_re
data = data.gsub(utf8_bom_re, '')
elsif data =~ /\A(\xEF\xBB\xBF|\xFE\xFF|\xFF\xFE)/
elsif data =~ Regexp.new("\\A(\\xFE\\xFF|\\xFF\\xFE)")
raise EncodingError, "#{pathname} has a unicode BOM." +
"Resave the file as UTF-8 or upgrade to Ruby 1.9"
end
Expand Down

0 comments on commit 72a43b6

Please sign in to comment.