summaryrefslogtreecommitdiffstats
path: root/web/react/utils/utils.jsx
diff options
context:
space:
mode:
authorReed Garmsen <rgarmsen2295@gmail.com>2015-06-30 12:30:11 -0700
committerReed Garmsen <rgarmsen2295@gmail.com>2015-06-30 12:30:11 -0700
commitae77db2145684e6d6db2b120c248279b55c5e407 (patch)
tree4105b53acebeea2c52351e8f392d256d2910e24f /web/react/utils/utils.jsx
parent7a7be75e742603d06927a488b136e1ed4432aac2 (diff)
downloadchat-ae77db2145684e6d6db2b120c248279b55c5e407.tar.gz
chat-ae77db2145684e6d6db2b120c248279b55c5e407.tar.bz2
chat-ae77db2145684e6d6db2b120c248279b55c5e407.zip
Changed keyword logic to use arrays rather than maps to remove highlighting of js object properties like constructor and __proto__
Diffstat (limited to 'web/react/utils/utils.jsx')
-rw-r--r--web/react/utils/utils.jsx10
1 files changed, 5 insertions, 5 deletions
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index d50a044bc..84bcc284d 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -398,10 +398,10 @@ module.exports.textToJsx = function(text, options) {
// Function specific regexes
var hashRegex = /^href="#[^"]+"|(#[A-Za-z]+[A-Za-z0-9_]*[A-Za-z0-9])$/g;
- var implicitKeywords = {};
+ var implicitKeywords = [];
var keywordArray = UserStore.getCurrentMentionKeys();
for (var i = 0; i < keywordArray.length; i++) {
- implicitKeywords[keywordArray[i]] = true;
+ implicitKeywords[i] = keywordArray[i];
}
var lines = text.split("\n");
@@ -427,7 +427,7 @@ module.exports.textToJsx = function(text, options) {
{
var name = explicitMention[1];
// do both a non-case sensitive and case senstive check
- var mClass = (('@'+name.toLowerCase()) in implicitKeywords || ('@'+name) in implicitKeywords) ? mentionClass : "";
+ var mClass = implicitKeywords.indexOf('@'+name.toLowerCase()) !== -1 || implicitKeywords.indexOf('@'+name) !== -1 ? mentionClass : "";
var suffix = word.match(puncEndRegex);
var prefix = word.match(puncStartRegex);
@@ -449,7 +449,7 @@ module.exports.textToJsx = function(text, options) {
} else if (trimWord.match(hashRegex)) {
var suffix = word.match(puncEndRegex);
var prefix = word.match(puncStartRegex);
- var mClass = trimWord in implicitKeywords || trimWord.toLowerCase() in implicitKeywords ? mentionClass : "";
+ var mClass = implicitKeywords.indexOf(trimWord) !== -1 || implicitKeywords.indexOf(trimWord.toLowerCase()) !== -1 ? mentionClass : "";
if (searchTerm === trimWord.substring(1).toLowerCase() || searchTerm === trimWord.toLowerCase()) {
highlightSearchClass = " search-highlight";
@@ -457,7 +457,7 @@ module.exports.textToJsx = function(text, options) {
inner.push(<span key={word+i+z+"_span"}>{prefix}<a key={word+i+z+"_hash"} className={"theme " + mClass + highlightSearchClass} href="#" onClick={function(value) { return function() { module.exports.searchForTerm(value); } }(trimWord)}>{trimWord}</a>{suffix} </span>);
- } else if (trimWord in implicitKeywords || trimWord.toLowerCase() in implicitKeywords) {
+ } else if (implicitKeywords.indexOf(trimWord) !== -1 || implicitKeywords.indexOf(trimWord.toLowerCase()) !== -1) {
var suffix = word.match(puncEndRegex);
var prefix = word.match(puncStartRegex);