File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change 22
33const getConstructorName = require ( '../getConstructorName' ) ;
44
5+ /**
6+ * @typedef { import('mongodb').TopologyDescription } TopologyDescription
7+ */
8+
9+ /**
10+ * Checks if topologyDescription contains servers connected to an atlas instance
11+ *
12+ * @param {TopologyDescription } topologyDescription
13+ * @returns {boolean }
14+ */
515module . exports = function isAtlas ( topologyDescription ) {
616 if ( getConstructorName ( topologyDescription ) !== 'TopologyDescription' ) {
717 return false ;
818 }
919
10- const hostnames = Array . from ( topologyDescription . servers . keys ( ) ) ;
11-
12- if ( hostnames . length === 0 ) {
20+ if ( topologyDescription . servers . size === 0 ) {
1321 return false ;
1422 }
1523
16- for ( let i = 0 , il = hostnames . length ; i < il ; ++ i ) {
17- const url = new URL ( hostnames [ i ] ) ;
18- if (
19- url . hostname . endsWith ( '.mongodb.net' ) === false ||
20- url . port !== '27017'
21- ) {
24+ for ( const server of topologyDescription . servers . values ( ) ) {
25+ if ( server . host . endsWith ( '.mongodb.net' ) === false || server . port !== 27017 ) {
2226 return false ;
2327 }
2428 }
29+
2530 return true ;
2631} ;
You can’t perform that action at this time.
0 commit comments