File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -1166,19 +1166,21 @@ export function checkParentDomainMatch(address: string, srvHost: string): void {
11661166 // an srvHostDomain = '.trusted.site'
11671167 // will not satisfy an addressDomain that endsWith '.fake-trusted.site'
11681168 const addressDomain = `.${ normalizedAddress . replace ( allCharacterBeforeFirstDot , '' ) } ` ;
1169- const srvHostDomain = srvIsLessThanThreeParts
1169+ let srvHostDomain = srvIsLessThanThreeParts
11701170 ? normalizedSrvHost
11711171 : `.${ normalizedSrvHost . replace ( allCharacterBeforeFirstDot , '' ) } ` ;
11721172
1173+ if ( ! srvIsLessThanThreeParts && ! srvHostDomain . startsWith ( '.' ) ) {
1174+ srvHostDomain = '.' + srvHostDomain ;
1175+ }
11731176 if (
11741177 srvIsLessThanThreeParts &&
11751178 normalizedAddress . split ( '.' ) . length <= normalizedSrvHost . split ( '.' ) . length
11761179 ) {
11771180 // TODO(NODE-3484): Replace with MongoConnectionStringError
11781181 throw new MongoAPIError ( 'Server record does not have least one more domain than parent URI' ) ;
11791182 }
1180-
1181- if ( ! ( '.' + addressDomain ) . endsWith ( '.' + srvHostDomain ) ) {
1183+ if ( ! addressDomain . endsWith ( srvHostDomain ) ) {
11821184 // TODO(NODE-3484): Replace with MongoConnectionStringError
11831185 throw new MongoAPIError ( 'Server record does not share hostname with parent URI' ) ;
11841186 }
You can’t perform that action at this time.
0 commit comments