From c3c1a1e14859e6716970283caeab0c4c3720862e Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 3 Sep 2010 23:25:57 +0200 Subject: Do not use ActionController::Base.page_cache_extension in initialize to not load more ActiveSupport than we need --- actionpack/lib/action_dispatch/middleware/static.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb index e7e335df49..581cadbeb4 100644 --- a/actionpack/lib/action_dispatch/middleware/static.rb +++ b/actionpack/lib/action_dispatch/middleware/static.rb @@ -7,16 +7,13 @@ module ActionDispatch @compiled_at = Regexp.compile(/^#{Regexp.escape(at)}/) unless @at.blank? @compiled_root = Regexp.compile(/^#{Regexp.escape(root)}/) @file_server = ::Rack::File.new(root) - - ext = ::ActionController::Base.page_cache_extension - @ext = "{,#{ext},/index#{ext}}" end def match?(path) path = path.dup if @compiled_at.blank? || path.sub!(@compiled_at, '') full_path = File.join(@root, ::Rack::Utils.unescape(path)) - paths = "#{full_path}#{@ext}" + paths = "#{full_path}#{ext}" matches = Dir[paths] match = matches.detect { |m| File.file?(m) } @@ -30,6 +27,13 @@ module ActionDispatch def call(env) @file_server.call(env) end + + def ext + @ext ||= begin + ext = ::ActionController::Base.page_cache_extension + "{,#{ext},/index#{ext}}" + end + end end class Static -- cgit v1.2.3