From 6238c84a98c5b77c576f903da67f2ed84ac06c81 Mon Sep 17 00:00:00 2001
From: Patrick Malouin
Date: Tue, 10 Mar 2020 17:25:43 -0400
Subject: [PATCH] fix: correctly use template string for connection string
error message
---
lib/core/uri_parser.js | 2 +-
test/unit/core/connection_string.test.js | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/core/uri_parser.js b/lib/core/uri_parser.js
index 0f51e0d72e..92c9a877b8 100644
--- a/lib/core/uri_parser.js
+++ b/lib/core/uri_parser.js
@@ -510,7 +510,7 @@ function assertTlsOptionsAreEqual(optionName, queryString, queryStringKeys) {
const firstValue = queryString[optionName][0];
queryString[optionName].forEach(tlsValue => {
if (tlsValue !== firstValue) {
- throw new MongoParseError('All values of ${optionName} must be the same.');
+ throw new MongoParseError(`All values of ${optionName} must be the same.`);
}
});
}
diff --git a/test/unit/core/connection_string.test.js b/test/unit/core/connection_string.test.js
index 6e5c914216..f9f9cd31be 100644
--- a/test/unit/core/connection_string.test.js
+++ b/test/unit/core/connection_string.test.js
@@ -203,6 +203,13 @@ describe('Connection String', function() {
done();
});
});
+
+ it('should validate non-equal tls values', function(done) {
+ parseConnectionString('mongodb://localhost/?tls=true&tls=false', err => {
+ expect(err).to.have.property('message', 'All values of tls must be the same.');
+ done();
+ });
+ });
});
describe('spec tests', function() {