Skip to content

Commit

Permalink
Merge pull request #297 from taylorstine/mongo_uri
Browse files Browse the repository at this point in the history
reverted uri encoding
  • Loading branch information
drew-gross committed Feb 8, 2016
2 parents 5c8f09b + f504cbb commit 123ac5f
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions ExportAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,8 @@ ExportAdapter.prototype.connect = function() {
return this.connectionPromise;
}

//http://regexr.com/3cncm
if (!this.mongoURI.match(/^mongodb:\/\/((.+):(.+)@)?([^:@]+):{0,1}([^:]+)\/(.+?)$/gm)) {
throw new Error("Invalid mongoURI: " + this.mongoURI)
}
var usernameStart = this.mongoURI.indexOf('://') + 3;
var lastAtIndex = this.mongoURI.lastIndexOf('@');
var encodedMongoURI = this.mongoURI;
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(encodedMongoURI, {uri_decode_auth:true});
return MongoClient.connect(this.mongoURI);
}).then((db) => {
this.db = db;
});
Expand Down

0 comments on commit 123ac5f

Please sign in to comment.