add getDbUrl fund

This commit is contained in:
casperlamboo 2017-11-06 10:24:16 +01:00
parent 22bd0b6953
commit 990b364635

View File

@ -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);