diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2010-11-22 09:07:44 -0500 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-11-22 23:06:13 +0100 |
commit | d04a21b36281a0608cdd72c02e4df3b1136f8887 (patch) | |
tree | eaca117046050e478b0c8139cce2c43e311fea7b | |
parent | cbb2651cc0e102b8f519acc41035adc32a8cc01b (diff) | |
download | rails-d04a21b36281a0608cdd72c02e4df3b1136f8887.tar.gz rails-d04a21b36281a0608cdd72c02e4df3b1136f8887.tar.bz2 rails-d04a21b36281a0608cdd72c02e4df3b1136f8887.zip |
declare regex as a constant
Signed-off-by: José Valim <jose.valim@gmail.com>
-rw-r--r-- | actionpack/lib/action_dispatch/http/mime_negotiation.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/http/mime_negotiation.rb b/actionpack/lib/action_dispatch/http/mime_negotiation.rb index 2b401114f0..68ba1a81b5 100644 --- a/actionpack/lib/action_dispatch/http/mime_negotiation.rb +++ b/actionpack/lib/action_dispatch/http/mime_negotiation.rb @@ -42,13 +42,15 @@ module ActionDispatch formats.first end + BROWSER_LIKE_ACCEPTS = /,\s*\*\/\*|\*\/\*\s*,/ + def formats accept = @env['HTTP_ACCEPT'] @env["action_dispatch.request.formats"] ||= if parameters[:format] Array(Mime[parameters[:format]]) - elsif xhr? || (accept && accept !~ /,\s*\*\/\*|\*\/\*\s*,/) + elsif xhr? || (accept && accept !~ BROWSER_LIKE_ACCEPTS) accepts else [Mime::HTML] |