From 4fb78a0b87b00f6efab4519bd5f744c100c2c76d Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Thu, 16 Jul 2020 17:42:17 -0400 Subject: [PATCH] Switch regex for delete_suffix in normalize_path --- actionpack/lib/action_dispatch/journey/router/utils.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/actionpack/lib/action_dispatch/journey/router/utils.rb b/actionpack/lib/action_dispatch/journey/router/utils.rb index 3c8b9a6eaa..55335e0e6b 100644 --- a/actionpack/lib/action_dispatch/journey/router/utils.rb +++ b/actionpack/lib/action_dispatch/journey/router/utils.rb @@ -19,11 +19,13 @@ module ActionDispatch encoding = path.encoding path = +"/#{path}" path.squeeze!("/") - path.sub!(%r{/+\Z}, "") - path.gsub!(/(%[a-f0-9]{2})/) { $1.upcase } - path = +"/" if path == "" + + unless path == "/" + path.delete_suffix!("/") + path.gsub!(/(%[a-f0-9]{2})/) { $1.upcase } + end + path.force_encoding(encoding) - path end # URI path and fragment escaping