From afb053b4d388137830320ed8dd49a40dc29a962c Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Sat, 16 Jun 2012 12:02:35 +0200 Subject: Respect absolute paths in compute_source_path. When using compute_source_path to determine the full path of an asset, if our source begins with '/', we don't want to include the directory. Examples are illustrative: > compute_source_path("foo", "stylesheets", "css") => "/Users/steve/src/my_app/public/stylesheets/foo.css" > compute_source_path("/foo", "stylesheets", "css") => "/Users/steve/src/my_app/public/foo.css" Before this patch, the second example would return the same as the first. Fixes #5680. --- actionpack/lib/action_view/asset_paths.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_view') diff --git a/actionpack/lib/action_view/asset_paths.rb b/actionpack/lib/action_view/asset_paths.rb index 4ce41d51f1..81880d17ea 100644 --- a/actionpack/lib/action_view/asset_paths.rb +++ b/actionpack/lib/action_view/asset_paths.rb @@ -35,7 +35,13 @@ module ActionView # Return the filesystem path for the source def compute_source_path(source, dir, ext) source = rewrite_extension(source, dir, ext) if ext - File.join(config.assets_dir, dir, source) + + sources = [] + sources << config.assets_dir + sources << dir unless source[0] == ?/ + sources << source + + File.join(sources) end def is_uri?(path) -- cgit v1.2.3