Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

mediaTypePriority not sorting correctly because it's using the wrong …

…object to sort
  • Loading branch information...
commit 52a6c30487a2b6a1647d1b2f19f095e9389fe2af 1 parent 8ed7607
@jdeerhake jdeerhake authored
Showing with 7 additions and 1 deletion.
  1. +3 −1 lib/mediaType.js
  2. +4 −0 test/mediaType.js
View
4 lib/mediaType.js
@@ -43,8 +43,10 @@ function parseMediaType(s) {
}
function getMediaTypePriority(type, accepted) {
- return (accepted.filter(function(a) {
+ return (accepted.map(function(a) {
return specify(type, a);
+ }).filter(function(a) {
+ return a;
}).sort(function (a, b) {
// revsort
return a.s > b.s ? -1 : 1;
View
4 test/mediaType.js
@@ -67,6 +67,10 @@
accept: 'text/*, text/html;q=0.5',
provided: ['text/html', 'text/plain'],
selected: ['text/plain', 'text/html']
+ }, {
+ accept: 'application/json, */*; q=0.01',
+ provided: ['text/html', 'application/json'],
+ selected: ['application/json', 'text/html']
}
];
Please sign in to comment.
Something went wrong with that request. Please try again.