We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6ce66e4 commit 1d8a84bCopy full SHA for 1d8a84b
lib/mongodb.js
@@ -325,6 +325,15 @@ MongoDB.prototype.connect = function(callback) {
325
if (callback) callback(err);
326
}
327
328
+ const urlObj = new URL(self.settings.url);
329
+
330
+ if ((urlObj.pathname === '' ||
331
+ urlObj.pathname.split('/')[1] === '') &&
332
+ typeof self.settings.database === 'string') {
333
+ urlObj.pathname = self.settings.database;
334
+ self.settings.url = urlObj.toString();
335
+ }
336
337
new mongodb.MongoClient(self.settings.url, validOptions).connect(function(
338
err,
339
client,
0 commit comments