fix: Improved phrase matching in search (#6800)

* fix: Improved phrase matching in search

* test
This commit is contained in:
Tom Moor
2024-04-13 07:01:26 -06:00
committed by GitHub
parent 8490f5d558
commit 054bddb666
3 changed files with 99 additions and 33 deletions

View File

@@ -37,9 +37,8 @@ type Props = {
const SEARCH_RESULT_REGEX = /<b\b[^>]*>(.*?)<\/b>/gi;
function replaceResultMarks(tag: string) {
// don't use SEARCH_RESULT_REGEX here as it causes
// an infinite loop to trigger a regex inside it's own callback
return tag.replace(/<b\b[^>]*>(.*?)<\/b>/gi, "$1");
// don't use SEARCH_RESULT_REGEX directly here as it causes an infinite loop
return tag.replace(new RegExp(SEARCH_RESULT_REGEX.source), "$1");
}
function DocumentListItem(