@@ -848,31 +848,51 @@ var connect = function(self, url, options, callback) {
848
848
) ;
849
849
}
850
850
851
- // Parse the string
852
- var object ;
853
- parse ( url , options , function ( err , connectionStringObject ) {
851
+ parse ( url , options , function ( err , object ) {
854
852
if ( err ) return console . log ( err ) ;
855
- object = connectionStringObject ;
856
- } ) ;
857
- var _finalOptions = createUnifiedOptions ( { } , object ) ;
858
- _finalOptions = mergeOptions ( _finalOptions , object , false ) ;
859
- _finalOptions = createUnifiedOptions ( _finalOptions , options ) ;
860
853
861
- // Check if we have connection and socket timeout set
862
- if ( _finalOptions . socketTimeoutMS == null ) _finalOptions . socketTimeoutMS = 360000 ;
863
- if ( _finalOptions . connectTimeoutMS == null ) _finalOptions . connectTimeoutMS = 30000 ;
854
+ // Parse the string
855
+ var _finalOptions = createUnifiedOptions ( { } , object ) ;
856
+ _finalOptions = mergeOptions ( _finalOptions , object , false ) ;
857
+ _finalOptions = createUnifiedOptions ( _finalOptions , options ) ;
864
858
865
- if ( _finalOptions . db_options && _finalOptions . db_options . auth ) {
866
- delete _finalOptions . db_options . auth ;
867
- }
859
+ // Check if we have connection and socket timeout set
860
+ if ( _finalOptions . socketTimeoutMS == null ) _finalOptions . socketTimeoutMS = 360000 ;
861
+ if ( _finalOptions . connectTimeoutMS == null ) _finalOptions . connectTimeoutMS = 30000 ;
868
862
869
- // Store the merged options object
870
- self . s . options = _finalOptions ;
863
+ if ( _finalOptions . db_options && _finalOptions . db_options . auth ) {
864
+ delete _finalOptions . db_options . auth ;
865
+ }
871
866
872
- // Failure modes
873
- if ( object . servers . length === 0 ) {
874
- throw new Error ( 'connection string must contain at least one seed host' ) ;
875
- }
867
+ // Store the merged options object
868
+ self . s . options = _finalOptions ;
869
+
870
+ // Failure modes
871
+ if ( object . servers . length === 0 ) {
872
+ throw new Error ( 'connection string must contain at least one seed host' ) ;
873
+ }
874
+
875
+ // Do we have a replicaset then skip discovery and go straight to connectivity
876
+ if ( _finalOptions . replicaSet || _finalOptions . rs_name ) {
877
+ return createReplicaset (
878
+ self ,
879
+ _finalOptions ,
880
+ connectHandler ( self , _finalOptions , connectCallback )
881
+ ) ;
882
+ } else if ( object . servers . length > 1 ) {
883
+ return createMongos (
884
+ self ,
885
+ _finalOptions ,
886
+ connectHandler ( self , _finalOptions , connectCallback )
887
+ ) ;
888
+ } else {
889
+ return createServer (
890
+ self ,
891
+ _finalOptions ,
892
+ connectHandler ( self , _finalOptions , connectCallback )
893
+ ) ;
894
+ }
895
+ } ) ;
876
896
877
897
function connectCallback ( err , topology ) {
878
898
if ( err && err . message === 'no mongos proxies found in seed list' ) {
@@ -895,19 +915,6 @@ var connect = function(self, url, options, callback) {
895
915
// Return the error and db instance
896
916
callback ( err , topology ) ;
897
917
}
898
-
899
- // Do we have a replicaset then skip discovery and go straight to connectivity
900
- if ( _finalOptions . replicaSet || _finalOptions . rs_name ) {
901
- return createReplicaset (
902
- self ,
903
- _finalOptions ,
904
- connectHandler ( self , _finalOptions , connectCallback )
905
- ) ;
906
- } else if ( object . servers . length > 1 ) {
907
- return createMongos ( self , _finalOptions , connectHandler ( self , _finalOptions , connectCallback ) ) ;
908
- } else {
909
- return createServer ( self , _finalOptions , connectHandler ( self , _finalOptions , connectCallback ) ) ;
910
- }
911
918
} ;
912
919
913
920
module . exports = MongoClient ;
0 commit comments