aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJorge Bejar <jorge@wyeworks.com>2015-12-03 15:19:25 -0300
committerJorge Bejar <jorge@wyeworks.com>2015-12-09 10:53:46 -0300
commit84e8accd6fb83031e4c27e44925d7596655285f7 (patch)
treec9636ca6fdd2413fb7f8e4a610798d172ed732f0 /actionpack
parentfa092512a00f6055326ae22e7b0d3218e8921a99 (diff)
downloadrails-84e8accd6fb83031e4c27e44925d7596655285f7.tar.gz
rails-84e8accd6fb83031e4c27e44925d7596655285f7.tar.bz2
rails-84e8accd6fb83031e4c27e44925d7596655285f7.zip
Do not add format key to request_params
I did this change but it is affecting how the request params end up after being processed by the router. To be in the safe side, I just take the format from the extension in the URL when is not present in those params and it's being used only for the `Request#formats` method
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/http/mime_negotiation.rb9
-rw-r--r--actionpack/lib/action_dispatch/http/parameters.rb19
-rw-r--r--actionpack/test/dispatch/routing_test.rb1
3 files changed, 11 insertions, 18 deletions
diff --git a/actionpack/lib/action_dispatch/http/mime_negotiation.rb b/actionpack/lib/action_dispatch/http/mime_negotiation.rb
index 7acf91902d..004713ec1a 100644
--- a/actionpack/lib/action_dispatch/http/mime_negotiation.rb
+++ b/actionpack/lib/action_dispatch/http/mime_negotiation.rb
@@ -67,6 +67,8 @@ module ActionDispatch
v = if params_readable
Array(Mime[parameters[:format]])
+ elsif format_from_path_extension
+ [Mime[format_from_path_extension]]
elsif use_accept_header && valid_accept_header
accepts
elsif xhr?
@@ -160,6 +162,13 @@ module ActionDispatch
def use_accept_header
!self.class.ignore_accept_header
end
+
+ def format_from_path_extension
+ path = @env['action_dispatch.original_path'] || @env['PATH_INFO']
+ if match = path && path.match(/\.(\w+)\z/)
+ match.captures.first
+ end
+ end
end
end
end
diff --git a/actionpack/lib/action_dispatch/http/parameters.rb b/actionpack/lib/action_dispatch/http/parameters.rb
index 9d450beae5..c9df787351 100644
--- a/actionpack/lib/action_dispatch/http/parameters.rb
+++ b/actionpack/lib/action_dispatch/http/parameters.rb
@@ -41,9 +41,9 @@ module ActionDispatch
# Returns a hash with the \parameters used to form the \path of the request.
# Returned hash keys are strings:
#
- # {'action' => 'my_action', 'controller' => 'my_controller', format => 'html'}
+ # {'action' => 'my_action', 'controller' => 'my_controller'}
def path_parameters
- get_header(PARAMETERS_KEY) || default_path_parameters
+ get_header(PARAMETERS_KEY) || {}
end
private
@@ -66,21 +66,6 @@ module ActionDispatch
def params_parsers
ActionDispatch::Request.parameter_parsers
end
-
- def default_path_parameters
- if format = format_from_path_extension
- { format: format }
- else
- {}
- end
- end
-
- def format_from_path_extension
- path = @env['action_dispatch.original_path'] || @env['PATH_INFO']
- if match = path && path.match(/\.(\w+)\z/)
- match.captures.first
- end
- end
end
end
end
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 1b711e1bf8..8972f3e74d 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -3272,7 +3272,6 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
expected_params = {
controller: 'downloads',
action: 'show',
- format: 'tar',
id: '1'
}