Skip to content

Commit

Permalink
Handle numbers in region
Browse files Browse the repository at this point in the history
  • Loading branch information
lledey committed Nov 10, 2016
1 parent 6e64fd0 commit 49dfa81
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var regex = /((([a-zA-Z]+(-[a-zA-Z]+){0,2})|\*)(;q=[0-1](\.[0-9]+)?)?)*/g;
var regex = /((([a-zA-Z]+(-[a-zA-Z0-9]+){0,2})|\*)(;q=[0-1](\.[0-9]+)?)?)*/g;

module.exports.parse = function(al){
var strings = (al || "").match(regex);
Expand Down
5 changes: 5 additions & 0 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ describe('accept-language#parse()', function(){
assertResult({ code: '*', quality: 0.8}, result[1]);
});

it('should correctly parse a region with numbers', function(){
var result = parser.parse('fr-150');
assertResult({ code: 'fr', region: '150', quality: 1.0}, result[0]);
});

it('should correctly parse complex set', function(){
var result = parser.parse('fr-CA,fr;q=0.8,en-US;q=0.6,en;q=0.4,*;q=0.1');
assertResult({ code: 'fr', region: 'CA', quality: 1.0}, result[0]);
Expand Down

0 comments on commit 49dfa81

Please sign in to comment.