diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-01-02 21:11:16 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-01-02 22:53:39 +0100 |
commit | 33841a9db3e560ef062d36d14ea07f7d71dd65ab (patch) | |
tree | 763ed8a5a06b24c516ac3c06e71ad553416c8f16 /actionpack/lib/action_dispatch/http | |
parent | f4dc7e3676a3a68d92772b5a466d54e430aa7b6a (diff) | |
download | rails-33841a9db3e560ef062d36d14ea07f7d71dd65ab.tar.gz rails-33841a9db3e560ef062d36d14ea07f7d71dd65ab.tar.bz2 rails-33841a9db3e560ef062d36d14ea07f7d71dd65ab.zip |
Backport #8701, do not append a second slash with `trailing_slash: true`
Diffstat (limited to 'actionpack/lib/action_dispatch/http')
-rw-r--r-- | actionpack/lib/action_dispatch/http/url.rb | 6 |
1 files changed, 5 insertions, 1 deletions
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 |