Skip to content

Commit

Permalink
Merge 11bdc64 into ad17d40
Browse files Browse the repository at this point in the history
  • Loading branch information
federomero committed Sep 28, 2014
2 parents ad17d40 + 11bdc64 commit 5bbe228
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/charset.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function getCharsetPriority(charset, accepted) {

function specify(charset, spec) {
var s = 0;
if(spec.charset === charset){
if(spec.charset.toUpperCase() === charset.toUpperCase()){
s |= 1;
} else if (spec.charset !== '*' ) {
return null
Expand Down
2 changes: 1 addition & 1 deletion lib/encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function getEncodingPriority(encoding, accepted) {

function specify(encoding, spec) {
var s = 0;
if(spec.encoding === encoding){
if(spec.encoding.toUpperCase() === encoding.toUpperCase()){
s |= 1;
} else if (spec.encoding !== '*' ) {
return null
Expand Down
6 changes: 3 additions & 3 deletions lib/language.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ function specify(language, spec) {
var p = parseLanguage(language)
if (!p) return null;
var s = 0;
if(spec.full === p.full){
if(spec.full.toUpperCase() === p.full.toUpperCase()){
s |= 4;
} else if (spec.prefix === p.full) {
} else if (spec.prefix.toUpperCase() === p.full.toUpperCase()) {
s |= 2;
} else if (spec.full === p.prefix) {
} else if (spec.full.toUpperCase() === p.prefix.toUpperCase()) {
s |= 1;
} else if (spec.full !== '*' ) {
return null
Expand Down
6 changes: 3 additions & 3 deletions lib/mediaType.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ function specify(type, spec) {
return null;
}

if(spec.type == p.type) {
if(spec.type.toUpperCase() == p.type.toUpperCase()) {
s |= 4
} else if(spec.type != '*') {
return null;
}

if(spec.subtype == p.subtype) {
if(spec.subtype.toUpperCase() == p.subtype.toUpperCase()) {
s |= 2
} else if(spec.subtype != '*') {
return null;
Expand All @@ -77,7 +77,7 @@ function specify(type, spec) {
var keys = Object.keys(spec.params);
if (keys.length > 0) {
if (keys.every(function (k) {
return spec.params[k] == '*' || spec.params[k] == p.params[k];
return spec.params[k] == '*' || spec.params[k].toUpperCase() == (p.params[k] || '').toUpperCase();
})) {
s |= 1
} else {
Expand Down
5 changes: 5 additions & 0 deletions test/charset.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
return test.done();
};

this["Should be case insensitive"] = function(test) {
test.deepEqual(preferredCharsets('iso-8859-1', ['ISO-8859-1']), ['ISO-8859-1']);
return test.done();
};

testCorrectCharset = function(c) {
return _this["Should return " + c.selected + " for accept-charset header " + c.accept + " with provided charset " + c.provided] = function(test) {
test.deepEqual(preferredCharsets(c.accept, c.provided), c.selected);
Expand Down
5 changes: 5 additions & 0 deletions test/encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
return test.done();
};

this["Should be case insensitive"] = function(test) {
test.deepEqual(preferredEncodings('IDENTITY', ['identity']), ['identity']);
return test.done();
};

testCorrectEncoding = function(c) {
return _this["Should return " + c.selected + " for accept-encoding header " + c.accept + " with provided encoding " + c.provided] = function(test) {
test.deepEqual(preferredEncodings(c.accept, c.provided), c.selected);
Expand Down
5 changes: 5 additions & 0 deletions test/language.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
return test.done();
};

this["Should be case insensitive"] = function(test) {
test.deepEqual(preferredLanguages('en-us', ['en-US']), ['en-US']);
return test.done();
};

testCorrectType = function(c) {
return _this["Should return " + c.selected + " for accept-language header " + c.accept + " with provided language " + c.provided] = function(test) {
test.deepEqual(preferredLanguages(c.accept, c.provided), c.selected);
Expand Down
6 changes: 6 additions & 0 deletions test/mediaType.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
return test.done();
};

this["Should be case insensitive"] = function(test) {
test.deepEqual(preferredMediaTypes('application/JSON', ['application/json']), ['application/json']);
return test.done();
};


testCorrectType = function(c) {
return _this["Should return " + c.selected + " for access header " + c.accept + " with provided types " + c.provided] = function(test) {
test.deepEqual(preferredMediaTypes(c.accept, c.provided), c.selected);
Expand Down

0 comments on commit 5bbe228

Please sign in to comment.