Permalink
Browse files

Check that db name and collection name exist in url before owerwrite …

…options matching values.
  • Loading branch information...
1 parent 3bb0665 commit dc4045a6dffb682a5118039345ce2f29115fb7cf @carlo-colombo carlo-colombo committed Jun 27, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/connect-mongo.js
View
4 lib/connect-mongo.js
@@ -49,11 +49,11 @@ module.exports = function(connect) {
if (db_url.pathname != undefined) {
var pathname = db_url.pathname.split('/');
- if (pathname.length >= 2) {
+ if (pathname.length >= 2 && pathname[1]) {
options.db = pathname[1];
}
- if (pathname.length >= 3) {
+ if (pathname.length >= 3 && pathname[2]) {
options.collection = pathname[2];
}
}

0 comments on commit dc4045a

Please sign in to comment.