CHANGE exactMatch to case insensitive && ADD safety to parameters check

This commit is contained in:
Norbert de Langen 2020-03-03 10:56:17 +01:00
parent ae02d61f02
commit 09fe2c3498
No known key found for this signature in database
GPG Key ID: 976651DA156C2825

View File

@ -14,7 +14,6 @@ export const prevent = (e: SyntheticEvent) => {
const toList = memoize(1)((dataset: Dataset) => Object.values(dataset)); const toList = memoize(1)((dataset: Dataset) => Object.values(dataset));
export type Item = StoriesHash[keyof StoriesHash]; export type Item = StoriesHash[keyof StoriesHash];
export type Dataset = Record<string, Item>; export type Dataset = Record<string, Item>;
export type SelectedSet = Record<string, boolean>; export type SelectedSet = Record<string, boolean>;
export type ExpandedSet = Record<string, boolean>; export type ExpandedSet = Record<string, boolean>;
@ -192,12 +191,20 @@ const fuse = memoize(5)(
}) })
); );
const exactMatch = memoize(1)(filter => (i: Item) => const exactMatch = memoize(1)((filter: string) => (i: Item) => {
(isStory(i) && i.kind.includes(filter)) || const reg = new RegExp(filter, 'i');
(i.name && i.name.includes(filter)) || return (
(i.parameters && i.parameters.fileName && i.parameters.fileName.includes(filter)) || i.isLeaf &&
(i.parameters && typeof i.parameters.notes === 'string' && i.parameters.notes.includes(filter)) ((isStory(i) && reg.test(i.kind)) ||
); (i.name && reg.test(i.name)) ||
(i.parameters &&
typeof i.parameters.fileName === 'string' &&
reg.test(i.parameters.fileName.toString())) ||
(i.parameters &&
typeof i.parameters.notes === 'string' &&
reg.test(i.parameters.notes.toString())))
);
});
export const toId = (base: string, addition: string) => export const toId = (base: string, addition: string) =>
base === '' ? `${addition}` : `${base}-${addition}`; base === '' ? `${addition}` : `${base}-${addition}`;