Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/components/codeKeywords/codeKeywords.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {KeywordSelector} from './keywordSelector';
import {OrgAuthTokenCreator} from './orgAuthTokenCreator';

export const KEYWORDS_REGEX = /\b___(?:([A-Z_][A-Z0-9_]*)\.)?([A-Z_][A-Z0-9_]*)___\b/g;

export const ORG_AUTH_TOKEN_REGEX = /___ORG_AUTH_TOKEN___/g;

type ChildrenItem = ReturnType<typeof Children.toArray>[number] | React.ReactNode;
Expand All @@ -24,6 +23,11 @@ export function makeKeywordsClickable(children: React.ReactNode) {
arr.push(updatedChild);
return arr;
}

// Reset regex lastIndex before testing to avoid stale state from previous matches
ORG_AUTH_TOKEN_REGEX.lastIndex = 0;
KEYWORDS_REGEX.lastIndex = 0;

if (ORG_AUTH_TOKEN_REGEX.test(child)) {
makeOrgAuthTokenClickable(arr, child);
} else if (KEYWORDS_REGEX.test(child)) {
Expand Down
Loading