diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-24 12:41:28 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-24 12:41:28 -0300 |
commit | ade105be402f178eae2eb3aaa7f221097a55eb2a (patch) | |
tree | 27333aed20eeabd89f1254f39bcbf67ebbfbe83a /actionpack/lib/action_dispatch | |
parent | 286a8b7f2af9a109787a3ae3b93b15175d0933b6 (diff) | |
parent | 82b4d879bf31ebf409217e2c770cedfb7c79a44a (diff) | |
download | rails-ade105be402f178eae2eb3aaa7f221097a55eb2a.tar.gz rails-ade105be402f178eae2eb3aaa7f221097a55eb2a.tar.bz2 rails-ade105be402f178eae2eb3aaa7f221097a55eb2a.zip |
Merge pull request #14986 from dlangevin/trailing-slash-url-generation
Fixes URL generation with trailing_slash: true
Conflicts:
actionpack/lib/action_dispatch/http/url.rb
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/http/url.rb | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index a6c17f50a5..4cba4f5f37 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -37,13 +37,7 @@ module ActionDispatch path = options[:script_name].to_s.chomp("/") path << options[:path].to_s - if options[:trailing_slash] - if path.include?('?') - path.sub!(/\?/, '/\&') - else - path.sub!(/[^\/]\z|\A\z/, '\&/') - end - end + add_trailing_slash(path) if options[:trailing_slash] result = path @@ -66,6 +60,18 @@ module ActionDispatch private + def add_trailing_slash(path) + # includes querysting + if path.include?('?') + path.sub!(/\?/, '/\&') + # does not have a .format + elsif !path.include?(".") + path.sub!(/[^\/]\z|\A\z/, '\&/') + end + + path + end + def build_host_url(options) if match = options[:host].match(HOST_REGEXP) options[:protocol] ||= match[1] unless options[:protocol] == false |