diff options
author | George Goldberg <george@gberg.me> | 2017-01-06 13:54:31 +0000 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-01-06 08:54:31 -0500 |
commit | c3f60d7ced72d274d960088bbf1a5b9ba3a6787b (patch) | |
tree | fcb6379cb7265b8d6b8db7fc34e4a1d4c1010e29 /webapp | |
parent | c81efa0b4e11fc1d86c6b16efd8670cf29756d81 (diff) | |
download | chat-c3f60d7ced72d274d960088bbf1a5b9ba3a6787b.tar.gz chat-c3f60d7ced72d274d960088bbf1a5b9ba3a6787b.tar.bz2 chat-c3f60d7ced72d274d960088bbf1a5b9ba3a6787b.zip |
PLT-4791 Fix hashtag highlight in search results. (#4977)
Diffstat (limited to 'webapp')
-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 |