diff --git a/src/utils/dbUtils.js b/src/utils/dbUtils.js index 2b68313..54e2b9a 100644 --- a/src/utils/dbUtils.js +++ b/src/utils/dbUtils.js @@ -14,6 +14,14 @@ export function getLegalDBName(input) { .replace(/(%..)/g, esc => `(${esc.substr(1)})`); } +export function getDbUrl(db) { + if (db.user) { + return `${db.protocol}${encodeURIComponent(db.user)}:${encodeURIComponent(db.password)}@${db.host}`; + } else { + return `${db.protocol}${db.host}`; + } +}; + const dbs = {}; export function getDb(dbUrl) { if (!dbs[dbUrl]) dbs[dbUrl] = new PouchDB(dbUrl);