Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/connection_string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,6 @@ export function parseOptions(
}
}

if (urlOptions.has('authSource')) {
// If authSource is an explicit key in the urlOptions we need to remove the dbName
urlOptions.delete('dbName');
}

const objectOptions = new CaseInsensitiveMap(
Object.entries(options).filter(([, v]) => v != null)
);
Expand Down
14 changes: 14 additions & 0 deletions test/unit/mongo_client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -788,3 +788,17 @@ describe('MongoOptions', function () {
expect(thrownError).to.have.property('code', 'ENOTFOUND');
});
});

describe('MongoClient', function () {
context('when a db is provided in the URI', function () {
const client = new MongoClient('mongodb://127.0.0.1:27017/dbName?authSource=admin');

context('when getting the db with no params', function () {
const db = client.db();

it('uses the db from the uri', function () {
expect(db.databaseName).to.equal('dbName');
});
});
});
});