summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2017-01-06 13:54:31 +0000
committerJoram Wilander <jwawilander@gmail.com>2017-01-06 08:54:31 -0500
commitc3f60d7ced72d274d960088bbf1a5b9ba3a6787b (patch)
treefcb6379cb7265b8d6b8db7fc34e4a1d4c1010e29 /webapp
parentc81efa0b4e11fc1d86c6b16efd8670cf29756d81 (diff)
downloadchat-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.jsx5
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