Skip to content

Commit

Permalink
Merge pull request #15 from lledey/region-numbers
Browse files Browse the repository at this point in the history
handle numbers in region
  • Loading branch information
matteofigus committed Nov 11, 2016
2 parents 6e64fd0 + bc602b6 commit c0a4e57
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "accept-language-parser",
"version": "1.2.0",
"version": "1.3.0",
"description": "Parse the accept-language header from a HTTP request",
"main": "index.js",
"scripts": {
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 c0a4e57

Please sign in to comment.