Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
fix(uri_parser): add replSet to exemption list for number coercion
Browse files Browse the repository at this point in the history
* fix(uri_parser) bypass number coercion for replicaSet values in connection string

* fix (uri_parser) do not coerce replicaSet with leading number to number
  • Loading branch information
lineus authored and mbroadst committed Oct 29, 2018
1 parent 2fa2140 commit d00b1ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/uri_parser.js
Expand Up @@ -175,7 +175,7 @@ const BOOLEAN_OPTIONS = new Set([
]);

// Known string options, only used to bypass Number coercion in `parseQueryStringItemValue`
const STRING_OPTIONS = new Set(['authsource']);
const STRING_OPTIONS = new Set(['authsource', 'replicaset']);

// Supported text representations of auth mechanisms
// NOTE: this list exists in native already, if it is merged here we should deduplicate
Expand Down
10 changes: 10 additions & 0 deletions test/tests/unit/connection_string_tests.js
Expand Up @@ -119,6 +119,16 @@ describe('Connection String', function() {
});
});

it('should parse a replicaSet with a leading number', function(done) {
parseConnectionString('mongodb://localhost/?replicaSet=123abc', (err, result) => {
expect(err).to.not.exist;
expect(result.options).to.have.property('replicaSet');
expect(result.options.replicaSet).to.equal('123abc');

done();
});
});

describe('validation', function() {
it('should validate compression options', function(done) {
parseConnectionString('mongodb://localhost/?zlibCompressionLevel=15', err => {
Expand Down

0 comments on commit d00b1ab

Please sign in to comment.