diff --git a/lib/action_controller/caching/actions.rb b/lib/action_controller/caching/actions.rb index 0127d61..e94c8d3 100644 --- a/lib/action_controller/caching/actions.rb +++ b/lib/action_controller/caching/actions.rb @@ -229,8 +229,15 @@ def initialize(controller, options = {}, infer_extension = true) private def normalize!(path) ext = URI.parser.escape(extension.to_s) if extension - path << "index" if path[-1] == ?/ - path << ".#{ext}" if extension && !path.split("?", 2).first.ends_with?(".#{ext}") + path << 'index' if path[-1] == '/' + if extension + s_path = path.split('?', 2) + unless s_path[0].ends_with?(".#{ext}") + s_path[0] << ".#{ext}" + path = s_path[0] + path << "?#{s_path[1]}" unless s_path[1].nil? + end + end URI.parser.unescape(path) end end