aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/mime_type.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller/mime_type.rb')
-rw-r--r--actionpack/lib/action_controller/mime_type.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/mime_type.rb b/actionpack/lib/action_controller/mime_type.rb
index b179fe2f89..44a60487b2 100644
--- a/actionpack/lib/action_controller/mime_type.rb
+++ b/actionpack/lib/action_controller/mime_type.rb
@@ -63,10 +63,12 @@ module Mime
def parse(accept_header)
# keep track of creation order to keep the subsequent sort stable
- index = 0
- list = accept_header.split(/,/).map! do |i|
- AcceptItem.new(index += 1, *i.split(/;\s*q=/))
- end.sort!
+ list = []
+ accept_header.split(/,/).each_with_index do |header, index|
+ params = header.split(/;\s*q=/)
+ list << AcceptItem.new(index, *params) unless params.empty?
+ end
+ list.sort!
# Take care of the broken text/xml entry by renaming or deleting it
text_xml = list.index("text/xml")