Skip to content

Commit 077b876

Browse files
author
Jessica Lord
authored
Resync Connection String Spec Tests (#1656)
* test(connection string): update to latest tests from specs * fix(url-parser): catch errors thrown by url parser
1 parent 33db3ca commit 077b876

File tree

3 files changed

+306
-266
lines changed

3 files changed

+306
-266
lines changed

lib/url_parser.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ module.exports = function(url, options, callback) {
1010
if (typeof options === 'function') (callback = options), (options = {});
1111
options = options || {};
1212

13-
let result = parser.parse(url, true);
13+
let result;
14+
try {
15+
result = parser.parse(url, true);
16+
} catch (e) {
17+
return callback(new Error('URL malformed, cannot be parsed'));
18+
}
19+
1420
if (result.protocol !== 'mongodb:' && result.protocol !== 'mongodb+srv:') {
1521
return callback(new Error('Invalid schema, expected `mongodb` or `mongodb+srv`'));
1622
}

0 commit comments

Comments
 (0)