diff --git a/ExportAdapter.js b/ExportAdapter.js index 89cb6c5900..ffb493fe7f 100644 --- a/ExportAdapter.js +++ b/ExportAdapter.js @@ -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; }); diff --git a/index.js b/index.js index 79a321986f..ae526e1938 100644 --- a/index.js +++ b/index.js @@ -51,7 +51,14 @@ function ParseServer(args) { } if (args.cloud) { addParseCloud(); - require(args.cloud); + if (typeof args.cloud === 'function') { + args.cloud(Parse) + } else if (typeof args.cloud === 'string') { + require(args.cloud); + } else { + throw "argument 'cloud' must either be a string or a function"; + } + } cache.apps[args.appId] = { diff --git a/transform.js b/transform.js index 7e19ba7035..1ff2c58113 100644 --- a/transform.js +++ b/transform.js @@ -691,7 +691,7 @@ function untransformObject(schema, className, mongoObject) { throw ('bad key in untransform: ' + key); } else { var expected = schema.getExpectedType(className, key); - if (expected == 'file') { + if (expected == 'file' && mongoObject[key]) { restObject[key] = { __type: 'File', name: mongoObject[key]