From 3c3d936f4d026336479c5ea0e953b8dcc823fbbd Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 8 Sep 2005 16:39:06 +0000 Subject: [PATCH] Fixed all AssetHelper methods to work with relative paths, such that javascript_include_tag('stdlib/standard') will look in /javascripts/stdlib/standard instead of '/stdlib/standard/' #1963 git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2156 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 2 ++ actionpack/lib/action_view/helpers/asset_tag_helper.rb | 2 +- actionpack/test/template/asset_tag_helper_test.rb | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index b55bd14f20..c46ed35f42 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed all AssetHelper methods to work with relative paths, such that javascript_include_tag('stdlib/standard') will look in /javascripts/stdlib/standard instead of '/stdlib/standard/' #1963 + * Avoid extending view instance with helper modules each request. Closes #1979 * Performance improvements to CGI methods. Closes #1980 [Skaes] diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index cd56592300..fea7abe3f9 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -119,7 +119,7 @@ def image_tag(source, options = {}) private def compute_public_path(source, dir, ext) - source = "/#{dir}/#{source}" unless source.include?("/") + source = "/#{dir}/#{source}" unless source.first == "/" || source.include?(":") source = "#{source}.#{ext}" unless source.include?(".") source = "#{@request.relative_url_root}#{source}" unless %r{^[-a-z]+://} =~ source ActionController::Base.asset_host + source diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index 045c4b1060..84c273a72f 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -37,6 +37,7 @@ def relative_url_root JavascriptPathToTag = { %(javascript_path("xmlhr")) => %(/javascripts/xmlhr.js), + %(javascript_path("super/xmlhr")) => %(/javascripts/super/xmlhr.js) } JavascriptIncludeToTag = { -- GitLab