diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-01-02 13:39:56 -0800 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-01-02 13:39:56 -0800 |
commit | 8af674714c8af702f640d61920df8675baca6d64 (patch) | |
tree | 7eff08f57313af5b2a47ab1a3f1465ed4deb8b11 /actionpack/lib/action_dispatch/http | |
parent | c9f0680cdfb9ea2f08a19c772a9e80b0f4cca231 (diff) | |
parent | 0b2ce7d955041107c70998c0d5b354404b83c74b (diff) | |
download | rails-8af674714c8af702f640d61920df8675baca6d64.tar.gz rails-8af674714c8af702f640d61920df8675baca6d64.tar.bz2 rails-8af674714c8af702f640d61920df8675baca6d64.zip |
Merge pull request #8701 from senny/8700_double_slash_with_trailing_slash
do not append a second slash when using `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 bced7d84c0..43f26d696d 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -32,7 +32,11 @@ module ActionDispatch params.reject! { |_,v| v.to_param.nil? } result = build_host_url(options) - result << (options[:trailing_slash] ? path.sub(/\?|\z/) { "/" + $& } : path) + if options[:trailing_slash] && !path.ends_with?('/') + result << path.sub(/(\?|\z)/) { "/" + $& } + else + result << path + end result << "?#{params.to_query}" unless params.empty? result << "##{Journey::Router::Utils.escape_fragment(options[:anchor].to_param.to_s)}" if options[:anchor] result |