mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
* Handle commas as separations in the query for CCS purposes * Add tests * Limit this to ccs queries, which just means they contain a :
This commit is contained in:
parent
88c47f5691
commit
ee0b5d57a4
2 changed files with 19 additions and 0 deletions
|
@ -21,6 +21,11 @@ describe('isQueryAMatch', () => {
|
|||
it('for a pattern that is only a wildcard', () => {
|
||||
expect(isQueryAMatch('*', 'es')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('for a pattern that contains commas', () => {
|
||||
expect(isQueryAMatch('cluster_one:kibana,cluster_two:kibana', 'cluster_one:kibana')).toBeTruthy();
|
||||
expect(isQueryAMatch('cluster_one:k*,cluster_two:kibana', 'cluster_one:kibana')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('returns false', () => {
|
||||
|
@ -31,5 +36,9 @@ describe('isQueryAMatch', () => {
|
|||
it('for a pattern with wildcards but does not remotely match', () => {
|
||||
expect(isQueryAMatch('k*b*', 'es')).toBeFalsy();
|
||||
});
|
||||
|
||||
it('for a pattern that contains commas but is not a CCS query', () => {
|
||||
expect(isQueryAMatch('kibana,es', 'kibana')).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
function isCCSQuery(query) {
|
||||
return query.includes(':');
|
||||
}
|
||||
|
||||
export const isQueryAMatch = (query, name) => {
|
||||
if (name === query) {
|
||||
return true;
|
||||
|
@ -20,5 +24,11 @@ export const isQueryAMatch = (query, name) => {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (query.includes(',')) {
|
||||
return query.split(',').reduce((isMatch, subQuery) => {
|
||||
return isMatch || isCCSQuery(subQuery) && isQueryAMatch(subQuery, name);
|
||||
}, false);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue