do not assume that there is no space between

leading */* and comma

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
Neeraj Singh 2010-11-22 08:58:01 -05:00 committed by José Valim
parent f5fba917f8
commit eb6ccc9953
2 changed files with 5 additions and 1 deletions

@ -48,7 +48,7 @@ def formats
@env["action_dispatch.request.formats"] ||=
if parameters[:format]
Array(Mime[parameters[:format]])
elsif xhr? || (accept && accept !~ /,\s*\*\/\*|\*\/\*,/)
elsif xhr? || (accept && accept !~ /,\s*\*\/\*|\*\/\*\s*,/)
accepts
else
[Mime::HTML]

@ -254,6 +254,10 @@ def test_json_or_yaml_with_leading_star_star
@request.accept = "*/*, application/json"
get :json_xml_or_html
assert_equal 'HTML', @response.body
@request.accept = "*/* , application/json"
get :json_xml_or_html
assert_equal 'HTML', @response.body
end
def test_json_or_yaml