Skip to content

Commit

Permalink
Detect format extension from right to left
Browse files Browse the repository at this point in the history
Fixes rails#226
  • Loading branch information
josh committed Oct 17, 2011
1 parent 9f3474d commit 07e1972
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sprockets/asset_attributes.rb
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/test_asset_attributes.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 07e1972

Please sign in to comment.