From 33841a9db3e560ef062d36d14ea07f7d71dd65ab Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Wed, 2 Jan 2013 21:11:16 +0100 Subject: Backport #8701, do not append a second slash with `trailing_slash: true` --- actionpack/lib/action_dispatch/http/url.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_dispatch') diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index 64459836b5..f07d5adc9b 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -43,7 +43,11 @@ module ActionDispatch params = options[:params] || {} params.reject! {|k,v| v.to_param.nil? } - rewritten_url << (options[:trailing_slash] ? path.sub(/\?|\z/) { "/" + $& } : path) + if options[:trailing_slash] && !path.ends_with?('/') + rewritten_url << path.sub(/(\?|\z)/) { "/" + $& } + else + rewritten_url << path + end rewritten_url << "?#{params.to_query}" unless params.empty? rewritten_url << "##{Journey::Router::Utils.escape_fragment(options[:anchor].to_param.to_s)}" if options[:anchor] rewritten_url -- cgit v1.2.3