From c77e592d7b366d7faa655b4368179990ae0c086d Mon Sep 17 00:00:00 2001 From: Vladislav Shub Date: Sun, 30 Jul 2017 14:44:10 +0300 Subject: [PATCH] fix(extension): settig the extension at the end of the path and not the params http://example.com/1.json?a=b instead of http://example.com/1?a=b.json --- lib/action_controller/caching/actions.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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