Skip to content

Commit

Permalink
Merge pull request rails#6423 from lest/patch-2
Browse files Browse the repository at this point in the history
assets: don't add extension if other given and file exists
  • Loading branch information
carlosantoniodasilva committed May 21, 2012
2 parents 64e12ff + 39f9f02 commit f051071
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
9 changes: 7 additions & 2 deletions actionpack/lib/sprockets/helpers/rails_helper.rb
Expand Up @@ -155,8 +155,13 @@ def rewrite_asset_path(source, dir, options = {})
end

def rewrite_extension(source, dir, ext)
if ext && File.extname(source) != ".#{ext}"
"#{source}.#{ext}"
source_ext = File.extname(source)
if ext && source_ext != ".#{ext}"
if !source_ext.empty? && asset_environment[source]
source
else
"#{source}.#{ext}"
end
else
source
end
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions actionpack/test/template/sprockets_helper_test.rb
Expand Up @@ -307,6 +307,9 @@ def compute_host(source, request, options = {})
assert_match %r{\A<link href="/assets/style-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />\Z},
stylesheet_link_tag("style", "style")

assert_match %r{\A<link href="/assets/style-[0-9a-f]+.ext" media="screen" rel="stylesheet" type="text/css" />\Z},
stylesheet_link_tag("style.ext")

@config.assets.compile = true
@config.assets.debug = true
assert_match %r{<link href="/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />},
Expand Down

0 comments on commit f051071

Please sign in to comment.