Skip to content

Commit 15ab259

Browse files
committed
Added encoding to user name and password
1 parent 522abdf commit 15ab259

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

ExportAdapter.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,19 @@ ExportAdapter.prototype.connect = function() {
3434
return this.connectionPromise;
3535
}
3636

37+
var usernameStart = this.mongoURI.indexOf('://') + 3;
38+
var lastAtIndex = this.mongoURI.lastIndexOf('@');
39+
var encodedMongoURI = this.mongoURI;
40+
var username = null;
41+
var password = null;
42+
var split = null
43+
if (lastAtIndex > 0) {
44+
split = this.mongoURI.slice(usernameStart, lastAtIndex).split(':');
45+
encodedMongoURI = this.mongoURI.slice(0, usernameStart) + encodeURIComponent(split[0]) + ':' + encodeURIComponent(split[1]) + this.mongoURI.slice(lastAtIndex);
46+
}
47+
3748
this.connectionPromise = Promise.resolve().then(() => {
38-
return MongoClient.connect(this.mongoURI);
49+
return MongoClient.connect(encodedMongoURI, {uri_decode_auth:true});
3950
}).then((db) => {
4051
this.db = db;
4152
});

0 commit comments

Comments
 (0)