Permalink
Browse files

Fix preferring earlier candidates

If Accept header has 'application/xml, application/json' and we pass ['application/json', 'application/xml'], we expect to get 'application/xml' as a result because it goes first in Accept header.
  • Loading branch information...
1 parent cdb34ae commit 96b6179e1b5eb3288bb4f72f104a4d06b20960da @xaka xaka committed Feb 4, 2014
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/Accept.coffee
View
@@ -207,9 +207,9 @@ getBestMediaMatch = (candidates) ->
return 1
# If all else is equal, prefer earlier candidates.
- if a.index > b.index
- return -1
if a.index < b.index
+ return -1
+ if a.index > b.index
return 1
candidates[acceptable[0].index] if acceptable[0].quality

0 comments on commit 96b6179

Please sign in to comment.