diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2013-01-10 12:43:57 -0800 |
---|---|---|
committer | Guillermo Iguaran <guilleiguaran@gmail.com> | 2013-01-10 12:43:57 -0800 |
commit | 686307cd90cd2153f73bd60a3810411584d3f6d3 (patch) | |
tree | 304970821fb3cecfc7062555d83c8a25090387d8 /actionpack/lib | |
parent | 002dfba66490d289bac897d1ba886310a672e779 (diff) | |
parent | 9bc5e6517c409d1fa71ba704bbf514afdbc0831b (diff) | |
download | rails-686307cd90cd2153f73bd60a3810411584d3f6d3.tar.gz rails-686307cd90cd2153f73bd60a3810411584d3f6d3.tar.bz2 rails-686307cd90cd2153f73bd60a3810411584d3f6d3.zip |
Merge pull request #8756 from causes/js_include_tag_fix
Fix javascript_include_tag when no js runtime is available
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/sprockets/helpers/rails_helper.rb | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb index bc573d8640..51f0cbb2da 100644 --- a/actionpack/lib/sprockets/helpers/rails_helper.rb +++ b/actionpack/lib/sprockets/helpers/rails_helper.rb @@ -157,18 +157,25 @@ module Sprockets end def rewrite_extension(source, dir, ext) - source_ext = File.extname(source) - if ext && source_ext != ".#{ext}" - if !source_ext.empty? && (asset = asset_environment[source]) && - asset.pathname.to_s =~ /#{source}\Z/ - source - else - "#{source}.#{ext}" - end - else + source_ext = File.extname(source)[1..-1] + + if !ext || ext == source_ext + source + elsif source_ext.blank? + "#{source}.#{ext}" + elsif exact_match_present?(source) source + else + "#{source}.#{ext}" end end + + def exact_match_present?(source) + pathname = asset_environment.resolve(source) + pathname.to_s =~ /#{Regexp.escape(source)}\Z/ + rescue Sprockets::FileNotFound + false + end end end end |