diff options
author | Christopher Speller <crspeller@gmail.com> | 2015-08-31 09:03:11 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2015-08-31 09:03:11 -0400 |
commit | ccb5d076d5fbb96de29492633ca83ecc30f36b37 (patch) | |
tree | b04191979b43f14a05454488bc1248084c010ec9 /web/react | |
parent | 2384fe0c7b682aa9b97f2cd33b3bfa24a79b98c6 (diff) | |
parent | b69221aa7fec759edb856e7b44ee24769b87486d (diff) | |
download | chat-ccb5d076d5fbb96de29492633ca83ecc30f36b37.tar.gz chat-ccb5d076d5fbb96de29492633ca83ecc30f36b37.tar.bz2 chat-ccb5d076d5fbb96de29492633ca83ecc30f36b37.zip |
Merge pull request #475 from nickago/MM-1773
MM-1773a Add wildcard searching for postgresql
Diffstat (limited to 'web/react')
-rw-r--r-- | web/react/utils/utils.jsx | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index 5266b1381..ecd6e5584 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -456,9 +456,21 @@ module.exports.textToJsx = function(text, options) { var mentionRegex = /^(?:@)([a-z0-9_]+)$/gi; // looks loop invariant but a weird JS bug needs it to be redefined here var explicitMention = mentionRegex.exec(trimWord); - if ((trimWord.toLowerCase().indexOf(searchTerm) > -1 || word.toLowerCase().indexOf(searchTerm) > -1) && searchTerm != '') { - - highlightSearchClass = ' search-highlight'; + if (searchTerm !== '') { + let searchWords = searchTerm.split(' '); + for (let idx in searchWords) { + let searchWord = searchWords[idx]; + if (searchWord === word.toLowerCase() || searchWord === trimWord.toLowerCase()) { + highlightSearchClass = ' search-highlight'; + break; + } else if (searchWord.charAt(searchWord.length - 1) === '*') { + let searchWordPrefix = searchWord.slice(0,-1); + if (trimWord.toLowerCase().indexOf(searchWordPrefix) > -1 || word.toLowerCase().indexOf(searchWordPrefix) > -1) { + highlightSearchClass = ' search-highlight'; + break; + } + } + } } if (explicitMention && |