Skip to content
This repository
Browse code

Merge pull request #6423 from lest/patch-2

assets: don't add extension if other given and file exists
  • Loading branch information...
commit f051071c00efdfe6444516104849cffd8885479b 2 parents 64e12ff + 39f9f02
Carlos Antonio da Silva authored May 21, 2012
9  actionpack/lib/sprockets/helpers/rails_helper.rb
@@ -155,8 +155,13 @@ def rewrite_asset_path(source, dir, options = {})
155 155
         end
156 156
 
157 157
         def rewrite_extension(source, dir, ext)
158  
-          if ext && File.extname(source) != ".#{ext}"
159  
-            "#{source}.#{ext}"
  158
+          source_ext = File.extname(source)
  159
+          if ext && source_ext != ".#{ext}"
  160
+            if !source_ext.empty? && asset_environment[source]
  161
+              source
  162
+            else
  163
+              "#{source}.#{ext}"
  164
+            end
160 165
           else
161 166
             source
162 167
           end
0  actionpack/test/fixtures/sprockets/app/stylesheets/style.ext
No changes.
3  actionpack/test/template/sprockets_helper_test.rb
@@ -307,6 +307,9 @@ def compute_host(source, request, options = {})
307 307
     assert_match %r{\A<link href="/assets/style-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />\Z},
308 308
       stylesheet_link_tag("style", "style")
309 309
 
  310
+    assert_match %r{\A<link href="/assets/style-[0-9a-f]+.ext" media="screen" rel="stylesheet" type="text/css" />\Z},
  311
+      stylesheet_link_tag("style.ext")
  312
+
310 313
     @config.assets.compile = true
311 314
     @config.assets.debug = true
312 315
     assert_match %r{<link href="/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />},

0 notes on commit f051071

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