Sanitising the paths to the couchDB data directories.
This commit is contained in:
parent
2c3566f686
commit
a72d8e42ad
|
@ -2,6 +2,7 @@ const PouchDB = require("pouchdb")
|
||||||
const replicationStream = require("pouchdb-replication-stream")
|
const replicationStream = require("pouchdb-replication-stream")
|
||||||
const allDbs = require("pouchdb-all-dbs")
|
const allDbs = require("pouchdb-all-dbs")
|
||||||
const { budibaseAppsDir } = require("../utilities/budibaseDir")
|
const { budibaseAppsDir } = require("../utilities/budibaseDir")
|
||||||
|
const { sanitise } = require("../utilities/sanitisedPath")
|
||||||
const env = require("../environment")
|
const env = require("../environment")
|
||||||
|
|
||||||
const COUCH_DB_URL = env.COUCH_DB_URL || `leveldb://${budibaseAppsDir()}/.data/`
|
const COUCH_DB_URL = env.COUCH_DB_URL || `leveldb://${budibaseAppsDir()}/.data/`
|
||||||
|
@ -26,4 +27,10 @@ const Pouch = PouchDB.defaults(POUCH_DB_DEFAULTS)
|
||||||
|
|
||||||
allDbs(Pouch)
|
allDbs(Pouch)
|
||||||
|
|
||||||
module.exports = Pouch
|
function PouchWrapper(instance) {
|
||||||
|
Pouch.apply(this, [sanitise(instance)])
|
||||||
|
}
|
||||||
|
|
||||||
|
PouchWrapper.prototype = Object.create(Pouch.prototype)
|
||||||
|
|
||||||
|
module.exports = PouchWrapper
|
||||||
|
|
|
@ -27,3 +27,12 @@ exports.join = function(...args) {
|
||||||
exports.resolve = function(...args) {
|
exports.resolve = function(...args) {
|
||||||
return path.resolve(...sanitiseArgs(args))
|
return path.resolve(...sanitiseArgs(args))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sanitise a single string
|
||||||
|
* @param string input string to sanitise
|
||||||
|
* @returns {string} the final sanitised string
|
||||||
|
*/
|
||||||
|
exports.sanitise = function(string) {
|
||||||
|
return sanitiseArgs([string])[0]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue