Merge pull request #33392 from azbshiri/actionpack/prevent-request-encoder-to-parse-nil-params

Prevent `RequestEncoder#encode_params` to parse falsey params
上级 eca9651f
......@@ -325,5 +325,12 @@
*Julian Nadeau*
* Prevent `RequestEncoder#encode_params` to parse falsey params
Now `RequestEncoder#encode_params` doesn't convert
falsey params into query string.
*Alireza Bashiri*
Please check [5-1-stable](https://github.com/rails/rails/blob/5-1-stable/actionpack/CHANGELOG.md) for previous changes.
......@@ -34,7 +34,7 @@ def accept_header
end
def encode_params(params)
@param_encoder.call(params)
@param_encoder.call(params) if params
end
def self.parser(content_type)
......
......@@ -1069,6 +1069,20 @@ def test_get_request_with_json_uses_method_override_and_sends_a_post_request
end
end
def test_get_request_with_json_excludes_null_query_string
with_routing do |routes|
routes.draw do
ActiveSupport::Deprecation.silence do
get ":action" => FooController
end
end
get "/foos_json", as: :json
assert_equal "http://www.example.com/foos_json", request.url
end
end
private
def post_to_foos(as:)
with_routing do |routes|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册