Skip to content

Loading…

don't add extension if other given and file exists #11

Merged
merged 1 commit into from

3 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 18, 2012
  1. @lest
This page is out of date. Refresh to see the latest.
View
9 lib/sprockets/rails/helpers/rails_helper.rb
@@ -158,8 +158,13 @@ def rewrite_asset_path(source, dir, options = {})
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
View
0 test/fixtures/app/stylesheets/style.ext
No changes.
View
3 test/sprockets_helper_test.rb
@@ -304,6 +304,9 @@ def compute_host(source, request, options = {})
assert_match %r{\A<link href="/assets/style-[0-9a-f]+.css" media="screen" rel="stylesheet" />\Z},
stylesheet_link_tag("style", "style")
+ assert_match %r{\A<link href="/assets/style-[0-9a-f]+.ext" media="screen" rel="stylesheet" />\Z},
+ stylesheet_link_tag("style.ext")
+
@config.assets.compile = true
@config.assets.debug = true
assert_match %r{<link href="/stylesheets/application.css" media="screen" rel="stylesheet" />},
Something went wrong with that request. Please try again.