From 4cf316fcd39dbb654bb07d80b0dfa9f8194c571d Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Sat, 12 Aug 2017 02:01:11 +0800 Subject: [PLT-7342] Add function and tests to specifically determine @all & @channel (#7181) * add function and tests to specifically determine @all & @channel * uodate per comments - regex and tests --- webapp/utils/post_utils.jsx | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'webapp/utils') diff --git a/webapp/utils/post_utils.jsx b/webapp/utils/post_utils.jsx index 9309e1e49..83fb666af 100644 --- a/webapp/utils/post_utils.jsx +++ b/webapp/utils/post_utils.jsx @@ -107,3 +107,12 @@ export function shouldShowDotMenu(post) { return false; } + +export function containsAtMention(text, key) { + if (!text || !key) { + return false; + } + + // This doesn't work for at mentions containing periods or hyphens + return new RegExp(`\\B${key}\\b`, 'i').test(text); +} -- cgit v1.2.3-1-g7c22