Added encoding to user name and password

This commit is contained in:
Taylor Stine
2016-02-01 14:15:30 -05:00
parent 522abdf606
commit 15ab25940e

View File

@@ -34,8 +34,19 @@ ExportAdapter.prototype.connect = function() {
return this.connectionPromise;
}
var usernameStart = this.mongoURI.indexOf('://') + 3;
var lastAtIndex = this.mongoURI.lastIndexOf('@');
var encodedMongoURI = this.mongoURI;
var username = null;
var password = null;
var split = null
if (lastAtIndex > 0) {
split = this.mongoURI.slice(usernameStart, lastAtIndex).split(':');
encodedMongoURI = this.mongoURI.slice(0, usernameStart) + encodeURIComponent(split[0]) + ':' + encodeURIComponent(split[1]) + this.mongoURI.slice(lastAtIndex);
}
this.connectionPromise = Promise.resolve().then(() => {
return MongoClient.connect(this.mongoURI);
return MongoClient.connect(encodedMongoURI, {uri_decode_auth:true});
}).then((db) => {
this.db = db;
});