reworked path pattern matching...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-09-14 03:16:26 +03:00
parent 41600d3f7e
commit 7505096dda
2 changed files with 27 additions and 21 deletions

View File

@ -334,16 +334,17 @@ module.BaseStore = {
args = pwpath.joinArgs('', args) args = pwpath.joinArgs('', args)
// NOTE: we are matching full paths only here so leading and // NOTE: we are matching full paths only here so leading and
// trainling '/' are optional... // trainling '/' are optional...
// NOTE: we ensure that we match full names and always split var pattern = new RegExp(`^\\/?`
// at '/' only... +RegExp.quoteRegExp(
var pattern = new RegExp(`^\\/?${ // remove leading/trailing '/'
path path.replace(/^\/|\/$/g, ''))
.replace(/^\/|\/$/g, '') // pattern: **
.replace(/\//g, '\\/') .replace(/\\\*\\\*/g, '(.*)')
//.replace(/\*\*/g, '.*') // pattern: *
.replace(/([\\\/]?)\*\*/g, '($1.*)') // NOTE: we are prepping the leading '.' of a pattern
.replace(/(?<=^|[\\\/]+|[^.])\*/g, '[^\\/]*') // dir for hidden tests...
}(?=[\\\\\/]|$)`) .replace(/(^|\\\/+)(\\\.|)([^\/]*)\\\*/g, '$1$2($3[^\\/]*)')
+'(?=[\\/]|$)', 'g')
/*/ XXX CACHED.... /*/ XXX CACHED....
var name = pwpath.basename(path) var name = pwpath.basename(path)
return [...(name.includes('*') ? return [...(name.includes('*') ?
@ -359,14 +360,24 @@ module.BaseStore = {
// skip metadata paths... // skip metadata paths...
if(p.includes('*')){ if(p.includes('*')){
return res } return res }
/*/ XXX HIDE this is wrong -- need to check for // XXX HIDE
// hidden paths within the match... var m = [...p.matchAll(pattern)]
if(pwpath.basename(p)[0] == '.' m.length > 0
&& !all){ && (!all ?
return res } // test if we need to hide things....
//*/ m.reduce(function(res, m){
return res === false ?
res
// XXX if we are using a partial pattern this is wrong...
// i.e. something like 'x*' (TEST)
: !/(^\.|[\\\/]\.)/.test(m[1])
}, true)
: true)
&& (m = m[0])
/*/
var m = p.match(pattern) var m = p.match(pattern)
m m
//*/
&& (!strict && (!strict
|| m[0] == p) || m[0] == p)
&& res.add( && res.add(

View File

@ -1,11 +1,6 @@
/********************************************************************** /**********************************************************************
* *
* *
* XXX BUG: .hide_paths:
* - hidden dir should hide all the children -- BROKEN
* (see /.hidden/suppage)
* - listing a hidden subtree should work regardless of :all -- BROKEN
* (see: /.hidden/tree)
* XXX might also be a good idea to investigate a .tree directory index * XXX might also be a good idea to investigate a .tree directory index
* as a supplement to .paths() * as a supplement to .paths()
* XXX BUG: changing the URL does not start the spinner... * XXX BUG: changing the URL does not start the spinner...