Skip to content

Commit ce38d6c

Browse files
committed
Reimplement quality sorting in mime_array
1 parent 3409da5 commit ce38d6c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/grape/middleware/formatter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def format_from_header
6363
def mime_array
6464
accept = headers['accept'] or return []
6565

66-
accept.gsub(/\b/,'').scan(%r((\w+/[\w+.-]+))).map {|(mime)|
66+
accept.gsub(/\b/,'').scan(%r((\w+/[\w+.-]+)(?:(?:;[^,]*?)?;\s*q=([\d.]+))?)).sort_by { |_, q| -q.to_f }.map {|mime, _|
6767
mime.sub(%r(vnd\.[^+]+\+), '')
6868
}
6969
end

0 commit comments

Comments
 (0)