Skip to content

Commit eafaf61

Browse files
ready for rereivew
1 parent 79f41e4 commit eafaf61

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

Diff for: src/utils.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,9 @@ export function checkParentDomainMatch(address: string, srvHost: string): void {
11771177
srvIsLessThanThreeParts &&
11781178
normalizedAddress.split('.').length <= normalizedSrvHost.split('.').length
11791179
) {
1180-
throw new MongoAPIError('Server record does not have at least one more domain level than parent URI');
1180+
throw new MongoAPIError(
1181+
'Server record does not have at least one more domain level than parent URI'
1182+
);
11811183
}
11821184
if (!addressDomain.endsWith(srvHostDomain)) {
11831185
throw new MongoAPIError('Server record does not share hostname with parent URI');

Diff for: test/unit/utils.test.ts

+32-8
Original file line numberDiff line numberDiff line change
@@ -940,13 +940,32 @@ describe('driver utils', function () {
940940
});
941941

942942
describe('checkParentDomainMatch()', () => {
943-
944943
const exampleSrvName = ['i-love-js', 'i-love-js.mongodb', 'i-love-javascript.mongodb.io'];
945-
const exampleSrvNameWithDot = ['i-love-js.', 'i-love-js.mongodb.', 'i-love-javascript.mongodb.io.'];
946-
const exampleHostNameWithoutDot = ['js-00.i-love-js', 'js-00.i-love-js.mongodb', 'i-love-javascript-00.mongodb.io'];
947-
const exampleHostNamesWithDot = ['js-00.i-love-js.', 'js-00.i-love-js.mongodb.', 'i-love-javascript-00.mongodb.io.'];
948-
const exampleHostNameThatDoNotMatchParent = ['js-00.i-love-js-a-little','js-00.i-love-js-a-little.mongodb', 'i-love-javascript-00.evil-mongodb.io'];
949-
const exampleHostNameThatDoNotMatchParentWithDot = ['i-love-js','', 'i-love-javascript-00.evil-mongodb.io.'];
944+
const exampleSrvNameWithDot = [
945+
'i-love-js.',
946+
'i-love-js.mongodb.',
947+
'i-love-javascript.mongodb.io.'
948+
];
949+
const exampleHostNameWithoutDot = [
950+
'js-00.i-love-js',
951+
'js-00.i-love-js.mongodb',
952+
'i-love-javascript-00.mongodb.io'
953+
];
954+
const exampleHostNamesWithDot = [
955+
'js-00.i-love-js.',
956+
'js-00.i-love-js.mongodb.',
957+
'i-love-javascript-00.mongodb.io.'
958+
];
959+
const exampleHostNameThatDoNotMatchParent = [
960+
'js-00.i-love-js-a-little',
961+
'js-00.i-love-js-a-little.mongodb',
962+
'i-love-javascript-00.evil-mongodb.io'
963+
];
964+
const exampleHostNameThatDoNotMatchParentWithDot = [
965+
'i-love-js',
966+
'',
967+
'i-love-javascript-00.evil-mongodb.io.'
968+
];
950969

951970
for (let num = 0; num < 3; num += 1) {
952971
context(`when srvName has ${num + 1} part${num !== 0 ? 's' : ''}`, () => {
@@ -959,7 +978,10 @@ describe('driver utils', function () {
959978

960979
it('with a trailing dot throws', () => {
961980
expect(() =>
962-
checkParentDomainMatch(exampleHostNameThatDoNotMatchParentWithDot[num], exampleSrvName[num])
981+
checkParentDomainMatch(
982+
exampleHostNameThatDoNotMatchParentWithDot[num],
983+
exampleSrvName[num]
984+
)
963985
).to.throw();
964986
});
965987
});
@@ -989,7 +1011,9 @@ describe('driver utils', function () {
9891011
it('does not accept address if it does not contain an extra domain level', () => {
9901012
expect(() =>
9911013
checkParentDomainMatch(exampleSrvNameWithDot[num], exampleSrvNameWithDot[num])
992-
).to.throw('Server record does not have at least one more domain level than parent URI');
1014+
).to.throw(
1015+
'Server record does not have at least one more domain level than parent URI'
1016+
);
9931017
});
9941018
}
9951019
});

0 commit comments

Comments
 (0)