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 2
2
3
3
const getConstructorName = require ( '../getConstructorName' ) ;
4
4
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
+ */
5
15
module . exports = function isAtlas ( topologyDescription ) {
6
16
if ( getConstructorName ( topologyDescription ) !== 'TopologyDescription' ) {
7
17
return false ;
8
18
}
9
19
10
- const hostnames = Array . from ( topologyDescription . servers . keys ( ) ) ;
11
-
12
- if ( hostnames . length === 0 ) {
20
+ if ( topologyDescription . servers . size === 0 ) {
13
21
return false ;
14
22
}
15
23
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 ) {
22
26
return false ;
23
27
}
24
28
}
29
+
25
30
return true ;
26
31
} ;
You can’t perform that action at this time.
0 commit comments