✨ Enhance search highlighting by replacing regex usage with replaceAll for improved readability and consistency
This commit is contained in:
@@ -411,11 +411,9 @@ function getHighlightedContent(lineContent) {
|
|||||||
if (!searchQuery.value.trim()) return lineContent;
|
if (!searchQuery.value.trim()) return lineContent;
|
||||||
|
|
||||||
const searchTerm = searchQuery.value;
|
const searchTerm = searchQuery.value;
|
||||||
const regex = new RegExp(
|
const escapedTerm = searchTerm.replace(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`);
|
||||||
`(${searchTerm.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')})`,
|
const regex = new RegExp(`(${escapedTerm})`, 'gi');
|
||||||
'gi'
|
return lineContent.replaceAll(regex, '<mark>$1</mark>');
|
||||||
);
|
|
||||||
return lineContent.replace(regex, '<mark>$1</mark>');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// URL state sync
|
// URL state sync
|
||||||
|
|||||||
Reference in New Issue
Block a user