eliotsykes / asset_fingerprint

Asset Fingerprint Plugin for Ruby on Rails - allows you to use md5 or timestamps in query string or in asset filenames as suggested by Google Page Speed

Home Page:http://github.com/eliotsykes/asset_fingerprint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

normalize_to_source should strip out query-string params

bradgessler opened this issue · comments

Rails will sometimes feed a query param into the image_path helper (for example, image_path('pic.gif', :mouseover => 'foo.gif'), which causes an error in asset fingerprint. The following patch fixes the problem:

--- a/vendor/plugins/asset_fingerprint/lib/asset_fingerprint/asset.rb
+++ b/vendor/plugins/asset_fingerprint/lib/asset_fingerprint/asset.rb
@@ -66,6 +66,8 @@ module AssetFingerprint
     end

     def self.normalize_to_source(source_or_absolute_path)
+      # Rails will sometimes feed a query string through here and screw up paths
+      source_or_absolute_path = source_or_absolute_path.split('?').first
       if absolute_path?(source_or_absolute_path)
         source = to_relative(source_or_absolute_path)
       else

Thanks for the fix Brad - much appreciated - its been committed to Asset Fingerprint, cheers, Eliot