From 788d674675f6f9b9cd1086548568f0bd69d190b8 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 16 Oct 2022 12:31:19 +0300 Subject: [PATCH] some refactoring... Signed-off-by: Alex A. Naanou --- pwiki/store/base.js | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/pwiki/store/base.js b/pwiki/store/base.js index 1c64a59..3334af9 100755 --- a/pwiki/store/base.js +++ b/pwiki/store/base.js @@ -500,11 +500,7 @@ module.BaseStore = { return this } var exists = await this.exists(path) path = exists - // XXX SANITIZE... || pwpath.sanitize(path, 'string') - /*/ - || pwpath.normalize(path, 'string') - //*/ path = pwpath.splitArgs(path).path data = data instanceof Promise ? await data @@ -654,17 +650,15 @@ module.MetaStore = { substores: undefined, substore: function(path){ - path = pwpath.normalize(path, 'string') + path = pwpath.sanitize(path, 'string') if(path in (this.substores ?? {})){ return path } - var root = path[0] == '/' var store = Object.keys(this.substores ?? {}) // normalize store paths to the given path... .filter(function(p){ - p = root ? - '/'+p - : 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] == '/' || path[p.length] == '\\')}) @@ -680,10 +674,8 @@ module.MetaStore = { isStore: function(path){ if(!this.substores){ return false } - path = pwpath.normalize(path, 'string') - path = path[0] == '/' ? - path.slice(1) - : path + path = pwpath.sanitize(path, 'string') + // XXX do we need this??? return !!this.substores[path] || !!this.substores['/'+ path] },