summaryrefslogtreecommitdiffstats
path: root/web/react/utils
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2015-10-26 08:56:30 -0400
committerChristopher Speller <crspeller@gmail.com>2015-10-26 08:56:30 -0400
commit3b3cc234eb87ad3358671944537300ac17a9db41 (patch)
tree86bf26a4a0ea1072be8c944d52cf0ebf798d350d /web/react/utils
parentf05da1fa6d028bfb15b2838abbb7976c29bff1cd (diff)
parente9812655f6cb7e9e6c06bc1b2a462efc106f52f7 (diff)
downloadchat-3b3cc234eb87ad3358671944537300ac17a9db41.tar.gz
chat-3b3cc234eb87ad3358671944537300ac17a9db41.tar.bz2
chat-3b3cc234eb87ad3358671944537300ac17a9db41.zip
Merge pull request #1181 from girishso/star-search2
PLT-747: Allow search results to match portions of words
Diffstat (limited to 'web/react/utils')
-rw-r--r--web/react/utils/text_formatting.jsx4
1 files changed, 2 insertions, 2 deletions
diff --git a/web/react/utils/text_formatting.jsx b/web/react/utils/text_formatting.jsx
index 5c2e68f1e..204c37364 100644
--- a/web/react/utils/text_formatting.jsx
+++ b/web/react/utils/text_formatting.jsx
@@ -246,7 +246,7 @@ function highlightSearchTerm(text, tokens, searchTerm) {
var newTokens = new Map();
for (const [alias, token] of tokens) {
- if (token.originalText === searchTerm) {
+ if (token.originalText.indexOf(searchTerm.replace(/\*$/, '')) > -1) {
const index = tokens.size + newTokens.size;
const newAlias = `MM_SEARCHTERM${index}`;
@@ -276,7 +276,7 @@ function highlightSearchTerm(text, tokens, searchTerm) {
return prefix + alias;
}
- return output.replace(new RegExp(`(^|\\W)(${searchTerm})\\b`, 'gi'), replaceSearchTermWithToken);
+ return output.replace(new RegExp(`()(${searchTerm})`, 'gi'), replaceSearchTermWithToken);
}
function replaceTokens(text, tokens) {