summaryrefslogtreecommitdiff
path: root/src/mongo/shell/mongo.js
diff options
context:
space:
mode:
authorMatt Cotter <matt.cotter@mongodb.com>2016-12-12 16:45:59 -0500
committerMatt Cotter <matt.cotter@mongodb.com>2016-12-13 16:12:18 -0500
commit68c8715feaa2ead6a3c25eb9aa512de779c4795d (patch)
tree79a444ddbb35c4d957b9f4aedd78bc9b6cd25d57 /src/mongo/shell/mongo.js
parent5d32ae99ab086e696bc9c5610c9f93220481e596 (diff)
downloadmongo-68c8715feaa2ead6a3c25eb9aa512de779c4795d.tar.gz
SERVER-27289 fix ConnectionString parsing in shell
Diffstat (limited to 'src/mongo/shell/mongo.js')
-rw-r--r--src/mongo/shell/mongo.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/mongo/shell/mongo.js b/src/mongo/shell/mongo.js
index cbc7386f0f9..3cb19816541 100644
--- a/src/mongo/shell/mongo.js
+++ b/src/mongo/shell/mongo.js
@@ -221,12 +221,13 @@ connect = function(url, user, pass) {
}
if (!url.startsWith("mongodb://")) {
- var colon = url.lastIndexOf(":");
- var slash = url.lastIndexOf("/");
+ const colon = url.lastIndexOf(":");
+ const slash = url.lastIndexOf("/");
+ if (slash == 0) {
+ throw Error("Failed to parse mongodb:// URL: " + url);
+ }
if (slash == -1 && colon == -1) {
url = "mongodb://127.0.0.1:27017/" + url;
- } else {
- url = "mongodb://" + url;
}
}