aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http/url.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_dispatch/http/url.rb')
-rw-r--r--actionpack/lib/action_dispatch/http/url.rb20
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