added string path handling for queries...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2019-05-18 03:23:43 +03:00
parent abbe36c8c5
commit 4527758a76

View File

@ -1090,16 +1090,23 @@ var BaseBrowserPrototype = {
&& function(elem, i, path){ && function(elem, i, path){
return pattern.test(elem.value) return pattern.test(elem.value)
|| pattern.test('/'+ path.join('/')) } }, || pattern.test('/'+ path.join('/')) } },
// path test... // string path test...
// NOTE: this does not go down branches that do not match the path... // XXX should 'B' be equivalent to '/B' or should it be more like '**/B'?
path: function(pattern){ strPath: function(pattern){
if(pattern instanceof Array || typeof(pattern) == typeof('str')){ if(typeof(pattern) == typeof('str')){
// XXX should 'B' be equivalent to '/B' or should it be more like '**/B'?
pattern = pattern instanceof Array ? pattern = pattern instanceof Array ?
pattern pattern
: pattern : pattern
.split(/[\\\/]/g) .split(/[\\\/]/g)
.filter(function(e){ return e.trim().length > 0 }) .filter(function(e){ return e.trim().length > 0 })
return this.path(pattern)
}
return false
},
// path test...
// NOTE: this does not go down branches that do not match the path...
path: function(pattern){
if(pattern instanceof Array){
// XXX add support for '**' ??? // XXX add support for '**' ???
var cmp = function(a, b){ var cmp = function(a, b){
return a.length == b.length return a.length == b.length
@ -1214,7 +1221,7 @@ var BaseBrowserPrototype = {
&& key == 'query') }) && key == 'query') })
.reduce(function(res, [_, get]){ .reduce(function(res, [_, get]){
return res return res
|| get.call(this.__search_test_generators__, pattern) }, false) ) || get.call(that.__search_test_generators__, pattern) }, false) )
return this.walk( return this.walk(
function(elem, i, path, next, stop){ function(elem, i, path, next, stop){