Highlights in excerpts now only work as word prefixes

Less confusing
This commit is contained in:
Simon Cambier
2022-10-28 20:38:25 +02:00
parent 6fb5edfacd
commit e6952d262d

View File

@@ -70,7 +70,7 @@ export function getAllIndices(text: string, regex: RegExp): SearchMatch[] {
*/
export function stringsToRegex(strings: string[]): RegExp {
if (!strings.length) return /^$/g
const joined = strings.map(s => escapeRegex(s)).join('|')
const joined = strings.map(s => '\\b' + escapeRegex(s)).join('|')
const reg = new RegExp(`(${joined})`, 'gi')
// console.log(reg)
return reg