diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-02-14 09:59:16 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-02-14 09:59:16 -0800 |
commit | 9d023c87de98f8c85574ecec019dd30a3dfc6f03 (patch) | |
tree | f6d089fb4685354bfc46cc088c252514c78f6958 /actionpack/lib | |
parent | cdbd64d1a3afd5a08c393403da61d8c7c1ae6c72 (diff) | |
parent | 19e9e67f95aa2f173e73ba11b22370c31b922103 (diff) | |
download | rails-9d023c87de98f8c85574ecec019dd30a3dfc6f03.tar.gz rails-9d023c87de98f8c85574ecec019dd30a3dfc6f03.tar.bz2 rails-9d023c87de98f8c85574ecec019dd30a3dfc6f03.zip |
Merge pull request #8704 from senny/remove_regexp_global_from_url_for
replace regexp global in #url_for
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/http/url.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index 43f26d696d..e9ef9ee9f2 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -32,8 +32,12 @@ module ActionDispatch params.reject! { |_,v| v.to_param.nil? } result = build_host_url(options) - if options[:trailing_slash] && !path.ends_with?('/') - result << path.sub(/(\?|\z)/) { "/" + $& } + if options[:trailing_slash] + if path.include?('?') + result << path.sub(/\?/, '/\&') + else + result << path.sub(/[^\/]\z|\A\z/, '\&/') + end else result << path end |