Regexp highlight / serach fix

This commit is contained in:
mrfry 2021-05-12 09:48:59 +02:00
parent 2ab3915448
commit a01761e729

View file

@ -4,8 +4,12 @@ function highlightText(text, toHighlight) {
if (!text) { if (!text) {
return '' return ''
} }
const re = new RegExp(toHighlight, 'gi') try {
return text.replace(re, `<mark>${toHighlight}</mark>`) const re = new RegExp(toHighlight, 'gi')
return text.replace(re, `<mark>${toHighlight}</mark>`)
} catch (e) {
return text
}
} }
export default function Question({ question, searchTerm }) { export default function Question({ question, searchTerm }) {