diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-07-16 18:15:15 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-07-16 18:15:15 -0700 |
commit | 0e26271456a772de5ce4c4c78cce3a275bcb89a8 (patch) | |
tree | e1dffe0007e2e04c5afeb7066b12a391b46be5e9 /actionpack/lib/action_dispatch/http | |
parent | 69799eda94c41461cf4a8157f457f0be4a012611 (diff) | |
download | rails-0e26271456a772de5ce4c4c78cce3a275bcb89a8.tar.gz rails-0e26271456a772de5ce4c4c78cce3a275bcb89a8.tar.bz2 rails-0e26271456a772de5ce4c4c78cce3a275bcb89a8.zip |
extract path building to a method
Diffstat (limited to 'actionpack/lib/action_dispatch/http')
-rw-r--r-- | actionpack/lib/action_dispatch/http/url.rb | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index fc1d0e6663..5decab3d8f 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -34,21 +34,23 @@ module ActionDispatch raise ArgumentError, 'Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true' end + if options[:only_path] + path_for options + else + protocol = options[:protocol] + port = options[:port] + build_host_url(host, port, protocol, options, path_for(options)) + end + end + + def path_for(options) result = options[:script_name].to_s.chomp("/") result << options[:path].to_s result = add_trailing_slash(result) if options[:trailing_slash] result = add_params options, result - result = add_anchor options, result - - if options[:only_path] - result - else - protocol = options[:protocol] - port = options[:port] - build_host_url(host, port, protocol, options, result) - end + add_anchor options, result end private |