jshttp / negotiator

An HTTP content negotiator for Node.js
MIT License
309 stars 33 forks source link

preferredMediaTypes() array quality sorting #8

Closed tj closed 11 years ago

tj commented 11 years ago

not sure if I'm doing something wrong, shouldn't these be sorted?

    var n = new Negotiator(this.req);
    return n.preferredMediaTypes();

where Accept is "application/*;q=0.2, image/jpeg;q=0.8, text/html" I get:

[ 'application/*', 'image/jpeg', 'text/html' ]
federomero commented 11 years ago

At the moment the preferredMediaTypes doesn't return an ordered array when no accept types are provided, the ordering happens only when you specify the media types you can respond to.

I can't think of any reason why the array shouldn't be ordered, I guess it's just because I didn't really use the invocation without params, I'll make the change tomorrow.

federomero commented 11 years ago

I just changed it on master and updated the npm package.

tj commented 11 years ago

great! thanks man