summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorReed Garmsen <rgarmsen2295@gmail.com>2016-02-05 14:08:05 -0800
committerReed Garmsen <rgarmsen2295@gmail.com>2016-02-05 14:08:05 -0800
commitcf9052d284fc6d57c5bf0afce474b72b34a0ecde (patch)
tree874b47543d3c6bd20f3a15b8bbd2a47e6ccb100f /web
parent29b5821c4098325ccec172ee0bc386c8b3b8f815 (diff)
downloadchat-cf9052d284fc6d57c5bf0afce474b72b34a0ecde.tar.gz
chat-cf9052d284fc6d57c5bf0afce474b72b34a0ecde.tar.bz2
chat-cf9052d284fc6d57c5bf0afce474b72b34a0ecde.zip
Limits hashtag linking to a minimum of three characters
Diffstat (limited to 'web')
-rw-r--r--web/react/utils/constants.jsx3
-rw-r--r--web/react/utils/text_formatting.jsx8
2 files changed, 9 insertions, 2 deletions
diff --git a/web/react/utils/constants.jsx b/web/react/utils/constants.jsx
index c1bd41b88..53f5e3c85 100644
--- a/web/react/utils/constants.jsx
+++ b/web/react/utils/constants.jsx
@@ -467,5 +467,6 @@ export default {
MAX_USERNAME_LENGTH: 15,
MIN_PASSWORD_LENGTH: 5,
MAX_PASSWORD_LENGTH: 50,
- TIME_SINCE_UPDATE_INTERVAL: 30000
+ TIME_SINCE_UPDATE_INTERVAL: 30000,
+ MIN_HASHTAG_LINK_LENGTH: 3
};
diff --git a/web/react/utils/text_formatting.jsx b/web/react/utils/text_formatting.jsx
index e837ded53..dae2252a6 100644
--- a/web/react/utils/text_formatting.jsx
+++ b/web/react/utils/text_formatting.jsx
@@ -248,8 +248,14 @@ function autolinkHashtags(text, tokens) {
const index = tokens.size;
const alias = `MM_HASHTAG${index}`;
+ let value = hashtag;
+
+ if (hashtag.length > Constants.MIN_HASHTAG_LINK_LENGTH) {
+ value = `<a class='mention-link' href='#' data-hashtag='${hashtag}'>${hashtag}</a>`;
+ }
+
tokens.set(alias, {
- value: `<a class='mention-link' href='#' data-hashtag='${hashtag}'>${hashtag}</a>`,
+ value,
originalText: hashtag
});