From 9a85da9367eaf65b4232a548ff1f2535ef3496cd Mon Sep 17 00:00:00 2001 From: Jorge Bejar Date: Tue, 29 Dec 2015 11:39:58 -0300 Subject: Rely on default Mime format when MimeNegotiation#format_from_path_extension is not a valid type Closes #22747 --- actionpack/lib/action_dispatch/http/mime_negotiation.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/action_dispatch/http/mime_negotiation.rb') diff --git a/actionpack/lib/action_dispatch/http/mime_negotiation.rb b/actionpack/lib/action_dispatch/http/mime_negotiation.rb index 0152c17ed4..eb9c2a18cb 100644 --- a/actionpack/lib/action_dispatch/http/mime_negotiation.rb +++ b/actionpack/lib/action_dispatch/http/mime_negotiation.rb @@ -67,8 +67,8 @@ module ActionDispatch v = if params_readable Array(Mime[parameters[:format]]) - elsif format = format_from_path_extension - Array(Mime[format]) + elsif extension_format = format_from_path_extension + [extension_format] elsif use_accept_header && valid_accept_header accepts elsif xhr? @@ -166,7 +166,7 @@ module ActionDispatch def format_from_path_extension path = @env['action_dispatch.original_path'] || @env['PATH_INFO'] if match = path && path.match(/\.(\w+)\z/) - match.captures.first + Mime[match.captures.first] end end end -- cgit v1.2.3 From 44ca804229cfdf7a149eed63a2f61f387f6f9fc8 Mon Sep 17 00:00:00 2001 From: Jorge Bejar Date: Tue, 29 Dec 2015 12:41:57 -0300 Subject: Format from Accept headers have higher precedence than path extension format --- actionpack/lib/action_dispatch/http/mime_negotiation.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_dispatch/http/mime_negotiation.rb') diff --git a/actionpack/lib/action_dispatch/http/mime_negotiation.rb b/actionpack/lib/action_dispatch/http/mime_negotiation.rb index eb9c2a18cb..e9b25339dc 100644 --- a/actionpack/lib/action_dispatch/http/mime_negotiation.rb +++ b/actionpack/lib/action_dispatch/http/mime_negotiation.rb @@ -67,10 +67,10 @@ module ActionDispatch v = if params_readable Array(Mime[parameters[:format]]) - elsif extension_format = format_from_path_extension - [extension_format] elsif use_accept_header && valid_accept_header accepts + elsif extension_format = format_from_path_extension + [extension_format] elsif xhr? [Mime[:js]] else -- cgit v1.2.3