mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
9 lines
262 B
TypeScript
9 lines
262 B
TypeScript
import xss from 'xss';
|
|
|
|
import escapeRegExp from 'lib/escapeRegExp';
|
|
|
|
export default function highlightText(text: string, query: string) {
|
|
const regex = new RegExp('(' + escapeRegExp(query) + ')', 'gi');
|
|
return xss(text.replace(regex, '<mark>$1</mark>'));
|
|
}
|