From 10aa728e8ba423e43fb96fa234309819e1a99574 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Sun, 27 Jan 2008 01:10:48 +0000 Subject: Don't repeatedly add relative_url_root to asset sources. Closes #10767 [tomtoday, Koz] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8740 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_view/helpers/asset_tag_helper.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index 12fbbb0dd6..883cd31373 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -450,9 +450,11 @@ module ActionView else source = "/#{dir}/#{source}" unless source[0] == ?/ if has_request - source = "#{@controller.request.relative_url_root}#{source}" + unless source =~ %r{^#{@controller.request.relative_url_root}/} + source = "#{@controller.request.relative_url_root}#{source}" + end end - rewrite_asset_path!(source) + source = rewrite_asset_path(source) if include_host host = compute_asset_host(source) @@ -504,11 +506,15 @@ module ActionView end end - # Break out the asset path rewrite so you wish to put the asset id + # Break out the asset path rewrite in case plugins wish to put the asset id # someplace other than the query string. - def rewrite_asset_path!(source) + def rewrite_asset_path(source) asset_id = rails_asset_id(source) - source << "?#{asset_id}" if !asset_id.blank? + if asset_id.blank? + source + else + source + "?#{asset_id}" + end end def javascript_src_tag(source, options) -- cgit v1.2.3