Skip to content

Commit

Permalink
Merge pull request #3016 from hapijs/chore/backport-domain-tld
Browse files Browse the repository at this point in the history
fix: domain default tld validation
  • Loading branch information
Marsup authored Jan 29, 2024
2 parents e7687b1 + 360bfd2 commit 8b7d0eb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/types/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ module.exports = Any.extend({
internals.addressOptions = function (options) {

if (!options) {
return options;
return internals.tlds || options; // $lab:coverage:ignore$
}

// minDomainSegments
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"dependencies": {
"@hapi/hoek": "^9.3.0",
"@hapi/topo": "^5.1.0",
"@sideway/address": "^4.1.4",
"@sideway/address": "^4.1.5",
"@sideway/formula": "^3.0.1",
"@sideway/pinpoint": "^2.0.0"
},
Expand Down
6 changes: 4 additions & 2 deletions test/types/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,8 @@ describe('string', () => {
type: 'string.domain',
context: { value: '"example.com', label: 'value' }
}],
['mail@example.com', false, '"value" must contain a valid domain name']
['mail@example.com', false, '"value" must contain a valid domain name'],
['joi.dev.whatevertldiwant', false, '"value" must contain a valid domain name']
]);
});

Expand Down Expand Up @@ -1465,7 +1466,8 @@ describe('string', () => {
type: 'string.email',
context: { value: '123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234567890123456789.12345678901234567890123456789012345678901234567890123456789.12345678901234567890123456789012345678901234567890123456789.12345.toolong.com', invalids: ['123456789012345678901234567890123456789012345678901234567890@12345678901234567890123456789012345678901234567890123456789.12345678901234567890123456789012345678901234567890123456789.12345678901234567890123456789012345678901234567890123456789.12345.toolong.com'], label: 'value' }
}],
['foo@bar%2ecom', false, '"value" must be a valid email']
['foo@bar%2ecom', false, '"value" must be a valid email'],
['invalid_tlds@email.ccc', false, '"value" must be a valid email']
]);
});

Expand Down

0 comments on commit 8b7d0eb

Please sign in to comment.