From f7cae37ce48a51b6d199635a05bb79132b8d5505 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 1 Jan 2018 02:26:25 +0900 Subject: [PATCH] Fix bug --- src/db/mongodb.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/db/mongodb.ts b/src/db/mongodb.ts index 1263ccaacd..bbbe70c34f 100644 --- a/src/db/mongodb.ts +++ b/src/db/mongodb.ts @@ -1,7 +1,10 @@ import config from '../conf'; -const uri = config.mongodb.user && config.mongodb.pass - ? `mongodb://${config.mongodb.user}:${config.mongodb.pass}@${config.mongodb.host}:${config.mongodb.port}/${config.mongodb.db}` +const u = config.mongodb.user ? encodeURIComponent(config.mongodb.user) : null; +const p = config.mongodb.pass ? encodeURIComponent(config.mongodb.pass) : null; + +const uri = u && p + ? `mongodb://${u}:${p}@${config.mongodb.host}:${config.mongodb.port}/${config.mongodb.db}` : `mongodb://${config.mongodb.host}:${config.mongodb.port}/${config.mongodb.db}`; /**