diff options
author | Jorge Bejar <jorge@wyeworks.com> | 2015-12-03 15:19:25 -0300 |
---|---|---|
committer | Jorge Bejar <jorge@wyeworks.com> | 2015-12-09 10:53:46 -0300 |
commit | 84e8accd6fb83031e4c27e44925d7596655285f7 (patch) | |
tree | c9636ca6fdd2413fb7f8e4a610798d172ed732f0 /actionpack/lib | |
parent | fa092512a00f6055326ae22e7b0d3218e8921a99 (diff) | |
download | rails-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/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/http/mime_negotiation.rb | 9 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/http/parameters.rb | 19 |
2 files changed, 11 insertions, 17 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 |