Skip to content

Commit

Permalink
Merge pull request #13 from jdeerhake/master
Browse files Browse the repository at this point in the history
mediaTypePriority not sorting correctly
  • Loading branch information
federomero committed Jan 24, 2014
2 parents 8ed7607 + c1ed406 commit cbb1985
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/mediaType.js
Expand Up @@ -43,9 +43,9 @@ function parseMediaType(s) {
}

function getMediaTypePriority(type, accepted) {
return (accepted.filter(function(a) {
return (accepted.map(function(a) {
return specify(type, a);
}).sort(function (a, b) {
}).filter(Boolean).sort(function (a, b) {
// revsort
return a.s > b.s ? -1 : 1;
})[0] || {q:0}).q;
Expand Down
4 changes: 4 additions & 0 deletions test/mediaType.js
Expand Up @@ -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']
}
];

Expand Down

0 comments on commit cbb1985

Please sign in to comment.