Skip to content

Commit

Permalink
Resync Connection String Spec Tests (#1656)
Browse files Browse the repository at this point in the history
* test(connection string): update to latest tests from specs

* fix(url-parser): catch errors thrown by url parser
  • Loading branch information
Jessica Lord authored Jan 30, 2018
1 parent 33db3ca commit 077b876
Show file tree
Hide file tree
Showing 3 changed files with 306 additions and 266 deletions.
8 changes: 7 additions & 1 deletion lib/url_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ module.exports = function(url, options, callback) {
if (typeof options === 'function') (callback = options), (options = {});
options = options || {};

let result = parser.parse(url, true);
let result;
try {
result = parser.parse(url, true);
} catch (e) {
return callback(new Error('URL malformed, cannot be parsed'));
}

if (result.protocol !== 'mongodb:' && result.protocol !== 'mongodb+srv:') {
return callback(new Error('Invalid schema, expected `mongodb` or `mongodb+srv`'));
}
Expand Down
Loading

0 comments on commit 077b876

Please sign in to comment.