Skip to content

Commit

Permalink
fix #24
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcg committed Dec 16, 2024
1 parent ddc92ff commit 273c091
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ tags.region = function(subtag) {
};

tags.type = function(subtag, type) {
var types = index[subtag.toLowerCase()];
var types = typeof subtag === 'string' && index[subtag.toLowerCase()];

if (types && types[type]) {
return new Subtag(subtag, type);
Expand Down
4 changes: 4 additions & 0 deletions test/src/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ describe('tags', function () {
assert.equal(tags.region('en'), null);
});

it('language() handles undefined argument', function() {
assert.ifError(tags.language(undefined));
});

it('language() returns subtag by language', function() {
var subtag;

Expand Down

0 comments on commit 273c091

Please sign in to comment.