Skip to content
Browse files

don't add extension if other given and file exists

  • Loading branch information...
1 parent 1b0d568 commit d059722ee6a70349831bde128d12f52ad45c95a3 @lest lest committed May 18, 2012
View
9 lib/sprockets/rails/helpers/rails_helper.rb
@@ -158,8 +158,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
View
0 test/fixtures/app/stylesheets/style.ext
No changes.
View
3 test/sprockets_helper_test.rb
@@ -304,6 +304,9 @@ def compute_host(source, request, options = {})
assert_match %r{\A<link href="/assets/style-[0-9a-f]+.css" media="screen" rel="stylesheet" />\Z},
stylesheet_link_tag("style", "style")
+ assert_match %r{\A<link href="/assets/style-[0-9a-f]+.ext" media="screen" rel="stylesheet" />\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" />},

0 comments on commit d059722

Please sign in to comment.
Something went wrong with that request. Please try again.