Skip to content
This repository was archived by the owner on Jun 10, 2018. It is now read-only.

Commit 54c9f50

Browse files
committed
Left most engine mime type matters
Fixes #478
1 parent 3255c8c commit 54c9f50

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/sprockets/asset_attributes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def format_content_type
8383
# `.coffee` files carry an implicit `application/javascript`
8484
# content type.
8585
def engine_content_type
86-
engine_extensions.reverse.each do |ext|
86+
engine_extensions.each do |ext|
8787
if mime_type = environment.engine_mime_types[ext]
8888
return mime_type
8989
end

test/test_asset_attributes.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ class TestAssetAttributes < Sprockets::TestCase
7070
pathname("jquery.tmpl.min.js").content_type
7171
assert_equal "application/javascript",
7272
pathname("application.coffee").content_type
73+
74+
env = Sprockets::Environment.new
75+
env.register_engine '.haml', proc {}, mime_type: 'text/html'
76+
env.register_engine '.ngt', proc {}, mime_type: 'application/javascript'
77+
assert_equal "application/javascript", env.attributes_for("foo.ngt.haml").content_type
7378
end
7479

7580
private

0 commit comments

Comments
 (0)