diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-20 15:29:40 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-20 15:29:40 -0700 |
commit | 5f49da8c6de50e0b8ab143faa1043a21239f70ec (patch) | |
tree | a00fffadbbd7545fed4be47daa670e00a77e5e4b /actionpack/lib/action_dispatch/http | |
parent | 960398cb261ba1a1ee331d79976be486f957cd78 (diff) | |
download | rails-5f49da8c6de50e0b8ab143faa1043a21239f70ec.tar.gz rails-5f49da8c6de50e0b8ab143faa1043a21239f70ec.tar.bz2 rails-5f49da8c6de50e0b8ab143faa1043a21239f70ec.zip |
push only_path conditional up
Diffstat (limited to 'actionpack/lib/action_dispatch/http')
-rw-r--r-- | actionpack/lib/action_dispatch/http/url.rb | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index dc4434309a..86ca909d27 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -37,7 +37,11 @@ module ActionDispatch path = options[:script_name].to_s.chomp("/") path << options[:path].to_s - result = build_host_url(options) + if options[:only_path] + result = '' + else + result = build_host_url(options) + end if options[:trailing_slash] if path.include?('?') @@ -65,28 +69,25 @@ module ActionDispatch private def build_host_url(options) - result = "" + if match = options[:host].match(HOST_REGEXP) + options[:protocol] ||= match[1] unless options[:protocol] == false + options[:host] = match[2] + options[:port] = match[3] unless options.key?(:port) + end - unless options[:only_path] - if match = options[:host].match(HOST_REGEXP) - options[:protocol] ||= match[1] unless options[:protocol] == false - options[:host] = match[2] - options[:port] = match[3] unless options.key?(:port) - end + options[:protocol] = normalize_protocol(options) + options[:host] = normalize_host(options) + options[:port] = normalize_port(options) - options[:protocol] = normalize_protocol(options) - options[:host] = normalize_host(options) - options[:port] = normalize_port(options) + result = options[:protocol] - result << options[:protocol] + if options[:user] && options[:password] + result << "#{Rack::Utils.escape(options[:user])}:#{Rack::Utils.escape(options[:password])}@" + end - if options[:user] && options[:password] - result << "#{Rack::Utils.escape(options[:user])}:#{Rack::Utils.escape(options[:password])}@" - end + result << options[:host] + result << ":#{options[:port]}" if options[:port] - result << options[:host] - result << ":#{options[:port]}" if options[:port] - end result end |