Browse Source

remove db utils

pull/6/head
Casper Lamboo 4 years ago
parent
commit
6e1660504b
  1. 29
      src/utils/dbUtils.js

29
src/utils/dbUtils.js

@ -1,29 +0,0 @@
import PouchDB from 'pouchdb';
export function getLegalDBName(input) {
return encodeURIComponent(input.toLowerCase())
.replace(/\./g, '%2E')
.replace(/!/g, '%21')
.replace(/~/g, '%7E')
.replace(/\*/g, '%2A')
.replace(/'/g, '%27')
.replace(/\(/g, '%28')
.replace(/\)/g, '%29')
.replace(/\-/g, '%2D')
.toLowerCase()
.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);
return dbs[dbUrl];
}
Loading…
Cancel
Save