Commit e03d702d by Hugo Häggmark Committed by GitHub

Fix: Prevents crash when searchFilter is non string (#20526)

parent 2079386a
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment