mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 10:03:33 -06:00
Fix: Prevents crash when searchFilter is non string (#20526)
This commit is contained in:
parent
2079386a7d
commit
e03d702d0c
@ -85,6 +85,14 @@ describe('containsSearchFilter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('when called with an object', () => {
|
||||
it('then it should return false', () => {
|
||||
const result = containsSearchFilter({});
|
||||
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe(`when called with a query without ${SEARCH_FILTER_VARIABLE}`, () => {
|
||||
it('then it should return false', () => {
|
||||
const result = containsSearchFilter('$app.*');
|
||||
|
@ -18,8 +18,8 @@ export const variableRegexExec = (variableString: string) => {
|
||||
|
||||
export const SEARCH_FILTER_VARIABLE = '__searchFilter';
|
||||
|
||||
export const containsSearchFilter = (query: string): boolean =>
|
||||
query ? query.indexOf(SEARCH_FILTER_VARIABLE) !== -1 : false;
|
||||
export const containsSearchFilter = (query: string | unknown): boolean =>
|
||||
query && typeof query === 'string' ? query.indexOf(SEARCH_FILTER_VARIABLE) !== -1 : false;
|
||||
|
||||
export const getSearchFilterScopedVar = (args: {
|
||||
query: string;
|
||||
|
Loading…
Reference in New Issue
Block a user