diff options
Diffstat (limited to 'webapp/utils')
-rw-r--r-- | webapp/utils/text_formatting.jsx | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/webapp/utils/text_formatting.jsx b/webapp/utils/text_formatting.jsx index 9f983a1ee..a18dd8627 100644 --- a/webapp/utils/text_formatting.jsx +++ b/webapp/utils/text_formatting.jsx @@ -452,6 +452,11 @@ export function highlightSearchTerms(text, tokens, searchPatterns) { output = output.replace(alias, newAlias); } + + // The pattern regexes are global, so calling pattern.test() above alters their + // state. Reset lastIndex to 0 between calls to test() to ensure it returns the + // same result every time it is called with the same value of token.originalText. + pattern.lastIndex = 0; } // the new tokens are stashed in a separate map since we can't add objects to a map during iteration |