also exclude lookbehinds from hightlighter seperator, to better support custom seperators for camelCasing + PascalCasing

This commit is contained in:
Hendrik 2023-06-28 21:53:13 +02:00 committed by GitHub
parent 9b0d2f7160
commit bb0d6950ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,9 +60,9 @@ export type SearchHighlightFactoryFn = (query: string) => SearchHighlightFn
export function setupSearchHighlighter(
config: SearchConfig
): SearchHighlightFactoryFn {
// Hack: temporarily remove pure lookaheads
// Hack: temporarily remove pure lookaheads and lookbehinds
const regex = config.separator.split("|").map(term => {
const temp = term.replace(/(\(\?[!=][^)]+\))/g, "")
const temp = term.replace(/(\(\?[!=<][^)]+\))/g, "")
return temp.length === 0 ? "<22>" : term
})
.join("|")