From 39f9f02ab04973b213bef8c6f4c1a71043ed709d Mon Sep 17 00:00:00 2001
From: Sergey Nartimov <just.lest@gmail.com>
Date: Mon, 21 May 2012 15:32:13 +0300
Subject: Assets: don't add extension if other given and file exists

We should lookup if asset without appended extension exists.
When sprockets are disabled the asset tag helpers incorporate
this logic. When sprockets are enabled we should have the same
logic.

For example, we have style.ext file in app/assets/stylesheets and
we use stylesheet_link_tag in the layout. In this case we should
have /assets/style.ext instead of /assets/style.ext.css in the
output.

Closes #6310
---
 actionpack/lib/sprockets/helpers/rails_helper.rb | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

(limited to 'actionpack/lib')

diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb
index 4e11221842..8ac137b4b5 100644
--- a/actionpack/lib/sprockets/helpers/rails_helper.rb
+++ b/actionpack/lib/sprockets/helpers/rails_helper.rb
@@ -155,8 +155,13 @@ module Sprockets
         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
-- 
cgit v1.2.3