diff --git a/lib/sprockets/asset_attributes.rb b/lib/sprockets/asset_attributes.rb index 9a07ee218..08eb4c418 100644 --- a/lib/sprockets/asset_attributes.rb +++ b/lib/sprockets/asset_attributes.rb @@ -69,7 +69,7 @@ def extensions # # => ".js" # def format_extension - extensions.detect { |ext| + extensions.reverse.detect { |ext| @environment.mime_types(ext) && !@environment.engines(ext) } end diff --git a/test/test_asset_attributes.rb b/test/test_asset_attributes.rb index 1e97b0eb2..75f27409b 100644 --- a/test/test_asset_attributes.rb +++ b/test/test_asset_attributes.rb @@ -58,6 +58,8 @@ class TestAssetAttributes < Sprockets::TestCase assert_equal ".js", pathname("jquery.min.js").format_extension assert_equal ".js", pathname("jquery.tmpl.js").format_extension assert_equal ".js", pathname("jquery.tmpl.min.js").format_extension + assert_equal ".js", pathname("jquery.csv.js").format_extension + assert_equal ".js", pathname("jquery.csv.min.js").format_extension env = Sprockets::Environment.new env.register_engine '.ms', Class.new @@ -77,6 +79,8 @@ class TestAssetAttributes < Sprockets::TestCase assert_equal [".erb"], pathname("jquery.js.erb").engine_extensions assert_equal [".erb"], pathname("jquery.min.js.erb").engine_extensions assert_equal [".coffee"], pathname("jquery.min.coffee").engine_extensions + assert_equal [".erb"], pathname("jquery.csv.min.js.erb").engine_extensions + assert_equal [".coffee", ".erb"], pathname("jquery.csv.min.js.coffee.erb").engine_extensions env = Sprockets::Environment.new env.register_engine '.ms', Class.new