diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2016-06-25 11:13:42 +0200 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2016-06-25 11:13:42 +0200 |
commit | cbceb78f38a1e51d02c19cd33f7299f3d0a79e95 (patch) | |
tree | 2ce5e3ea571fe6fea7b4e5c677ed3ed6fa8e0f4f /actionpack | |
parent | 0e8b4e1170c7da6c83949cd6d495c288c3af1089 (diff) | |
download | rails-cbceb78f38a1e51d02c19cd33f7299f3d0a79e95.tar.gz rails-cbceb78f38a1e51d02c19cd33f7299f3d0a79e95.tar.bz2 rails-cbceb78f38a1e51d02c19cd33f7299f3d0a79e95.zip |
Extract method to share path expansion logic.
Then just yield the location for the place where we need some extra processing.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/testing/integration.rb | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb index 7ebce95b29..5627e79bb7 100644 --- a/actionpack/lib/action_dispatch/testing/integration.rb +++ b/actionpack/lib/action_dispatch/testing/integration.rb @@ -327,19 +327,17 @@ module ActionDispatch request_encoder = RequestEncoder.encoder(as) if path =~ %r{://} - location = URI.parse(path) - https! URI::HTTPS === location if location.scheme - if url_host = location.host - default = Rack::Request::DEFAULT_PORTS[location.scheme] - url_host += ":#{location.port}" if default != location.port - host! url_host + path = build_expanded_path(path, request_encoder) do |location| + https! URI::HTTPS === location if location.scheme + + if url_host = location.host + default = Rack::Request::DEFAULT_PORTS[location.scheme] + url_host += ":#{location.port}" if default != location.port + host! url_host + end end - path = request_encoder.append_format_to location.path - path = location.query ? "#{path}?#{location.query}" : path elsif as - location = URI.parse(path) - path = request_encoder.append_format_to location.path - path = location.query ? "#{path}?#{location.query}" : path + path = build_expanded_path(path, request_encoder) end hostname, port = host.split(':') @@ -398,6 +396,13 @@ module ActionDispatch "#{env['rack.url_scheme']}://#{env['SERVER_NAME']}:#{env['SERVER_PORT']}#{path}" end + def build_expanded_path(path, request_encoder) + location = URI.parse(path) + yield location if block_given? + path = request_encoder.append_format_to location.path + location.query ? "#{path}?#{location.query}" : path + end + class RequestEncoder # :nodoc: @encoders = {} |