Skip to content

Commit ccf9f1f

Browse files
authored
fix search when search term contains parethesis ( special characters) (#438)
Signed-off-by: maissa SOUISSI <[email protected]>
1 parent 49f7046 commit ccf9f1f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/components/search/search-item.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ export const HighlightedText: FunctionComponent<HighlightedTextProps> = ({
5353
text,
5454
highlight,
5555
}) => {
56-
const parts = text.split(new RegExp(`(${highlight})`, 'gi'));
56+
const escapedHighlight = highlight.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
57+
const parts = text.split(new RegExp(`(${escapedHighlight})`, 'gi'));
5758
return (
5859
<span>
5960
{parts.map((part, i) =>

0 commit comments

Comments
 (0)