mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
This commit is contained in:
parent
55a60ab11f
commit
cbc1dee01d
2 changed files with 16 additions and 2 deletions
|
@ -57,6 +57,18 @@ describe('fieldWildcard', function () {
|
|||
});
|
||||
|
||||
describe('filter', function () {
|
||||
it('filters nothing when given undefined', function () {
|
||||
const filter = fieldWildcardFilter();
|
||||
const original = [
|
||||
'foo',
|
||||
'bar',
|
||||
'baz',
|
||||
1234
|
||||
];
|
||||
|
||||
expect(original.filter(filter)).to.eql(original);
|
||||
});
|
||||
|
||||
it('filters nothing when given an empty array', function () {
|
||||
const filter = fieldWildcardFilter([]);
|
||||
const original = [
|
||||
|
|
|
@ -26,7 +26,8 @@ export function FieldWildcardProvider(config) {
|
|||
return new RegExp('^' + glob.split('*').map(escapeRegExp).join('.*') + '$');
|
||||
});
|
||||
|
||||
function fieldWildcardMatcher(globs) {
|
||||
// Note that this will return an essentially noop function if globs is undefined.
|
||||
function fieldWildcardMatcher(globs = []) {
|
||||
return function matcher(val) {
|
||||
// do not test metaFields or keyword
|
||||
if (metaFields.indexOf(val) !== -1) {
|
||||
|
@ -36,7 +37,8 @@ export function FieldWildcardProvider(config) {
|
|||
};
|
||||
}
|
||||
|
||||
function fieldWildcardFilter(globs) {
|
||||
// Note that this will return an essentially noop function if globs is undefined.
|
||||
function fieldWildcardFilter(globs = []) {
|
||||
const matcher = fieldWildcardMatcher(globs);
|
||||
return function filter(val) {
|
||||
return !matcher(val);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue