lib/juicer/cache_buster.rb in juicer-1.1.0 vs lib/juicer/cache_buster.rb in juicer-1.1.1

- old
+ new

@@ -82,24 +82,24 @@ def self.path(file, type = :soft, parameter = DEFAULT_PARAMETER) return file if file =~ /data:.*;base64/ type = [:soft, :hard, :rails, :md5].include?(type) ? type : :soft parameter = nil if type == :rails file = self.clean(file, parameter) - filename = file.split("?").first + filename = file.split(/[\?\#]/).first raise ArgumentError.new("#{file} could not be found") unless File.exists?(filename) mtime = File.mtime(filename).to_i if type == :soft parameter = "#{parameter}=".sub(/^=$/, '') return "#{file}#{file.index('?') ? '&' : '?'}#{parameter}#{mtime}" elsif type == :rails return "#{file}#{file.index('?') ? '' : "?#{mtime}"}" elsif type == :md5 md5 = Digest::MD5.hexdigest(File.read(filename)) - return file.sub(/(\.[^\.]+$)/, "-#{parameter}#{md5}" + '\1') + return file.sub(/(\.[^\.]+([\?\#].*)?$)/, "-#{parameter}#{md5}" + '\1') end - file.sub(/(\.[^\.]+$)/, "-#{parameter}#{mtime}" + '\1') + file.sub(/(\.[^\.]+([\?\#].*)?$)/, "-#{parameter}#{mtime}" + '\1') end # # Add a md5 cache buster to a filename. The parameter is an optional prefix # that is added before the md5 digest. It results in filenames of the form: