Skip to content

Commit 33068db

Browse files
committed
fix: Removed RegExp for strings match
1 parent 36071e9 commit 33068db

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/pages/Stream/Views/Explore/JSONView.tsx

+4-10
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,8 @@ const { setInstantSearchValue, applyInstantSearch, applyJqSearch, setRowNumber,
3535
const Item = (props: { header: string | null; value: string; highlight: boolean }) => {
3636
return (
3737
<span className={classes.itemContainer}>
38-
{props.header && (
39-
<span style={{ background: props.highlight ? 'yellow' : 'transparent' }} className={classes.itemHeader}>
40-
{props.header}:{' '}
41-
</span>
42-
)}
43-
<span className={classes.itemValue}>
44-
<span style={{ background: props.highlight ? 'yellow' : 'transparent' }}>{props.value}</span>{' '}
38+
<span style={{ background: props.highlight ? 'yellow' : 'transparent' }} className={classes.itemHeader}>
39+
{props.header}: {props.value}
4540
</span>
4641
</span>
4742
);
@@ -145,13 +140,12 @@ const Row = (props: {
145140
const JsonRows = (props: { isSearching: boolean; setContextMenu: any }) => {
146141
const [{ pageData, instantSearchValue, rowNumber }, setLogsStore] = useLogsStore((store) => store.tableOpts);
147142
const disableHighlight = props.isSearching || _.isEmpty(instantSearchValue) || isJqSearch(instantSearchValue);
148-
const regExp = disableHighlight ? null : new RegExp(instantSearchValue, 'i');
149143

150144
const shouldHighlight = useCallback(
151145
(header: string | null, val: number | string | Date | null) => {
152-
return !!regExp?.test(_.toString(val)) || !!regExp?.test(_.toString(header));
146+
return String(val).includes(instantSearchValue) || String(header).includes(instantSearchValue);
153147
},
154-
[regExp],
148+
[instantSearchValue],
155149
);
156150

157151
const handleRowClick = (index: number, event: React.MouseEvent) => {

src/pages/Stream/providers/LogsProvider.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,6 @@ const filterAndSortData = (
504504

505505
const searchAndSortData = (opts: { searchValue: string }, data: Log[]) => {
506506
const { searchValue } = opts;
507-
const regExp = new RegExp(searchValue, 'i');
508507
const filteredData = _.isEmpty(searchValue)
509508
? data
510509
: (_.reduce(
@@ -515,7 +514,10 @@ const searchAndSortData = (opts: { searchValue: string }, data: Log[]) => {
515514
.map(([key, value]) => [key, _.toString(value)])
516515
.value();
517516

518-
const doesMatch = _.some(allValues, ([key, value]) => regExp.test(key) || regExp.test(value));
517+
const doesMatch = _.some(
518+
allValues,
519+
([key, value]) => key.includes(searchValue) || value.includes(searchValue),
520+
);
519521

520522
return doesMatch ? [...acc, d] : acc;
521523
},

0 commit comments

Comments
 (0)