File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed
packages/mongodb-build-info Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,10 @@ export async function identifyServerName({
158158} : IdentifyServerNameOptions ) : Promise < string > {
159159 try {
160160 const hostname = getHostnameFromUrl ( connectionString ) ;
161+ if ( hostname . match ( ATLAS_REGEX ) ) {
162+ return 'mongodb' ;
163+ }
164+
161165 if ( hostname . match ( COSMOS_DB_REGEX ) ) {
162166 return 'cosmosdb' ;
163167 }
Original file line number Diff line number Diff line change @@ -69,6 +69,13 @@ export const CMD_LINE_OPTS = {
6969 ok : 1 ,
7070} ;
7171
72+ export const ATLAS_URIS = [
73+ 'mongodb+srv://x:y@cluster0.nxezgv0.mongodb.net/' ,
74+ 'mongodb+srv://x:y@cluster0.nxezgv0.mongodb-qa.net/' ,
75+ 'mongodb+srv://x:y@cluster0.nxezgv0.mongodb-dev.net/' ,
76+ 'mongodb://x:y@atlas-stream-64ba1372b2a9f1545031f34d-gkumd.virginia-usa.a.query.mongodb.net/' ,
77+ ] ;
78+
7279export const COSMOS_DB_URI = [
7380 'mongodb://x:y@compass-serverless.mongo.cosmos.azure.com:19555/?ssl=true&retrywrites=false&maxIdleTimeMS=120000&appName=@compass-serverless@' ,
7481 'mongodb://x:y@compass.mongo.cosmos.azure.com:19555/?ssl=true&retrywrites=false&maxIdleTimeMS=120000&appName=@compass@' ,
Original file line number Diff line number Diff line change @@ -436,6 +436,16 @@ describe('mongodb-build-info', function () {
436436 return Promise . reject ( new Error ( 'Should not be called' ) ) ;
437437 }
438438
439+ it ( 'reports MongoDB (when Atlas)' , async function ( ) {
440+ for ( const connectionString of fixtures . ATLAS_URIS ) {
441+ const result = await identifyServerName ( {
442+ connectionString,
443+ adminCommand : fail ,
444+ } ) ;
445+ expect ( result ) . to . equal ( 'mongodb' ) ;
446+ }
447+ } ) ;
448+
439449 it ( 'reports CosmosDB' , async function ( ) {
440450 for ( const connectionString of fixtures . COSMOS_DB_URI ) {
441451 const result = await identifyServerName ( {
You can’t perform that action at this time.
0 commit comments