1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Cache computed public asset paths.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7611 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jeremy Kemper 2007-09-24 09:18:30 +00:00
parent 8db51ee3c0
commit 7f9a6c0d92

View file

@ -384,27 +384,31 @@ module ActionView
# a single or wildcarded asset host, if configured, with the correct
# request protocol.
def compute_public_path(source, dir, ext = nil, include_host = true)
source += ".#{ext}" if File.extname(source).blank? && ext
@@computed_public_paths ||= {}
@@computed_public_paths["#{@controller.request.protocol}#{@controller.request.relative_url_root}#{dir}#{source}#{ext}#{include_host}"] ||=
begin
source += ".#{ext}" if File.extname(source).blank? && ext
if source =~ %r{^[-a-z]+://}
source
else
source = "/#{dir}/#{source}" unless source[0] == ?/
source = "#{@controller.request.relative_url_root}#{source}"
rewrite_asset_path!(source)
if source =~ %r{^[-a-z]+://}
source
else
source = "/#{dir}/#{source}" unless source[0] == ?/
source = "#{@controller.request.relative_url_root}#{source}"
rewrite_asset_path!(source)
if include_host
host = compute_asset_host(source)
if include_host
host = compute_asset_host(source)
unless host.blank? or host =~ %r{^[-a-z]+://}
host = "#{@controller.request.protocol}#{host}"
unless host.blank? or host =~ %r{^[-a-z]+://}
host = "#{@controller.request.protocol}#{host}"
end
"#{host}#{source}"
else
source
end
end
"#{host}#{source}"
else
source
end
end
end
# Pick an asset host for this source. Returns nil if no host is set,