(query: string[], caseSensitive: boolean)
| 31 | } |
| 32 | |
| 33 | function buildRegex(query: string[], caseSensitive: boolean) { |
| 34 | const _query = query |
| 35 | .filter((text) => text.length !== 0) |
| 36 | .map((text) => escapeRegExp(text.trim())); |
| 37 | if (!_query.length) { |
| 38 | return null; |
| 39 | } |
| 40 | |
| 41 | return new RegExp(`(${_query.join("|")})`, `${caseSensitive ? "" : "i"}g`); |
| 42 | } |
| 43 | |
| 44 | interface HighlightOptions { |
| 45 | text: string; |
no test coverage detected