mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-30 02:20:08 +00:00
some refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
65f0c6823d
commit
788d674675
@ -500,11 +500,7 @@ module.BaseStore = {
|
|||||||
return this }
|
return this }
|
||||||
var exists = await this.exists(path)
|
var exists = await this.exists(path)
|
||||||
path = exists
|
path = exists
|
||||||
// XXX SANITIZE...
|
|
||||||
|| pwpath.sanitize(path, 'string')
|
|| pwpath.sanitize(path, 'string')
|
||||||
/*/
|
|
||||||
|| pwpath.normalize(path, 'string')
|
|
||||||
//*/
|
|
||||||
path = pwpath.splitArgs(path).path
|
path = pwpath.splitArgs(path).path
|
||||||
data = data instanceof Promise ?
|
data = data instanceof Promise ?
|
||||||
await data
|
await data
|
||||||
@ -654,17 +650,15 @@ module.MetaStore = {
|
|||||||
substores: undefined,
|
substores: undefined,
|
||||||
|
|
||||||
substore: function(path){
|
substore: function(path){
|
||||||
path = pwpath.normalize(path, 'string')
|
path = pwpath.sanitize(path, 'string')
|
||||||
if(path in (this.substores ?? {})){
|
if(path in (this.substores ?? {})){
|
||||||
return path }
|
return path }
|
||||||
var root = path[0] == '/'
|
|
||||||
var store = Object.keys(this.substores ?? {})
|
var store = Object.keys(this.substores ?? {})
|
||||||
// normalize store paths to the given path...
|
// normalize store paths to the given path...
|
||||||
.filter(function(p){
|
.filter(function(p){
|
||||||
p = root ?
|
|
||||||
'/'+p
|
|
||||||
: p
|
|
||||||
return path.startsWith(p)
|
return path.startsWith(p)
|
||||||
|
// only keep whole path elements...
|
||||||
|
// NOTE: this prevents matching 'a/b' with 'a/bbb', for example.
|
||||||
&& (path[p.length] == null
|
&& (path[p.length] == null
|
||||||
|| path[p.length] == '/'
|
|| path[p.length] == '/'
|
||||||
|| path[p.length] == '\\')})
|
|| path[p.length] == '\\')})
|
||||||
@ -680,10 +674,8 @@ module.MetaStore = {
|
|||||||
isStore: function(path){
|
isStore: function(path){
|
||||||
if(!this.substores){
|
if(!this.substores){
|
||||||
return false }
|
return false }
|
||||||
path = pwpath.normalize(path, 'string')
|
path = pwpath.sanitize(path, 'string')
|
||||||
path = path[0] == '/' ?
|
// XXX do we need this???
|
||||||
path.slice(1)
|
|
||||||
: path
|
|
||||||
return !!this.substores[path]
|
return !!this.substores[path]
|
||||||
|| !!this.substores['/'+ path] },
|
|| !!this.substores['/'+ path] },
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user