diff --git a/index.js b/index.js index d6795ab..49d8749 100644 --- a/index.js +++ b/index.js @@ -101,7 +101,7 @@ function recursive_filter (input, filters, children_key = 'children') { data[i] = e; let match = true; for (const filter of filters) { - const search_str = to_search_string(e, filter.field); + const search_str = to_search_string (e, filter.field); if (!filter.filter.test (search_str)) { match = false; diff --git a/test/index.js b/test/index.js index dbd6b23..bfa7702 100644 --- a/test/index.js +++ b/test/index.js @@ -179,7 +179,7 @@ test ('recursive filter multifield', (t) => { ]; const filtered = [ { name: 'foo', f: 'include' } ]; const filter = { - fields: [ + field: [ 'name', 'f' ], @@ -189,21 +189,12 @@ test ('recursive filter multifield', (t) => { t.deepEqual (filtered, result); }); -test ('recursive filter multifield input error', (t) => { - t.notThrows (() => { - util.recursive_filter ( - [ { foo: 'bar' } ], - [ { fields: '', field: 'foo', filter: /a/u } ] - ); - }); -}); - test ('recursive filter undefined multifield', (t) => { const res = util.recursive_filter ( [ { foo: 'bar' } ], [ { - fields: [ + field: [ 'foo', 'bar' ],