Skip to content

Commit fe4eacb

Browse files
committed
handling of error
1 parent 994d0d0 commit fe4eacb

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/components/common/helpers/Helpers.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,10 +1013,14 @@ export const highlightSearchedText = (searchText: string, matchString: string):
10131013
if (!searchText) {
10141014
return matchString
10151015
}
1016-
const highlightText = (highlighted) => `<mark>${highlighted}</mark>`
1017-
const escapedSearchText = searchText.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // Escape special characters handling
1018-
const regex = new RegExp(escapedSearchText, 'gi');
1019-
return matchString.replace(regex, highlightText)
1016+
try {
1017+
const highlightText = (highlighted) => `<mark>${highlighted}</mark>`
1018+
const escapedSearchText = searchText.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') // Escape special characters handling
1019+
const regex = new RegExp(escapedSearchText, 'gi')
1020+
return matchString.replace(regex, highlightText)
1021+
} catch (err) {
1022+
return matchString
1023+
}
10201024
}
10211025

10221026
export const trackByGAEvent = (category: string, action: string): void => {

0 commit comments

Comments
 (0)