mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 11:27:07 +00:00
Fix check
This commit is contained in:
@@ -18,19 +18,21 @@ export const HighlightText = ({
|
|||||||
const escapedSearchTerm = searchTerm.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
const escapedSearchTerm = searchTerm.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||||
const regex = new RegExp(escapedSearchTerm, "gi");
|
const regex = new RegExp(escapedSearchTerm, "gi");
|
||||||
|
|
||||||
for (const match of text.matchAll(regex)) {
|
text.replace(regex, (match: string, offset: number) => {
|
||||||
if (match.index > lastIndex) {
|
if (offset > lastIndex) {
|
||||||
parts.push(<span key={`pre-${lastIndex}`}>{text.substring(lastIndex, match.index)}</span>);
|
parts.push(<span key={`pre-${lastIndex}`}>{text.substring(lastIndex, offset)}</span>);
|
||||||
}
|
}
|
||||||
|
|
||||||
parts.push(
|
parts.push(
|
||||||
<span key={`match-${match.index}`} className={highlightClassName || "bg-yellow/30"}>
|
<span key={`match-${offset}`} className={highlightClassName || "bg-yellow/30"}>
|
||||||
{match[0]}
|
{match}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
||||||
lastIndex = match.index + match[0].length;
|
lastIndex = offset + match.length;
|
||||||
}
|
|
||||||
|
return match;
|
||||||
|
});
|
||||||
|
|
||||||
if (lastIndex < text.length) {
|
if (lastIndex < text.length) {
|
||||||
parts.push(<span key={`post-${lastIndex}`}>{text.substring(lastIndex)}</span>);
|
parts.push(<span key={`post-${lastIndex}`}>{text.substring(lastIndex)}</span>);
|
||||||
|
|||||||
Reference in New Issue
Block a user