Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

minor: Simplify `usermention` regex and properly use capturing groups.

akshatdaltonf4891e7e4f10
diff --git a/static/third/marked/lib/marked.js b/static/third/marked/lib/marked.js
index 5653376ccfe..b6c0116a106 100644
--- a/static/third/marked/lib/marked.js
+++ b/static/third/marked/lib/marked.js
@@ -544,7 +544,7 @@ inline.zulip = merge({}, inline.breaks, {
'\ud83d[\ude80-\udeff]|\ud83e[\udd00-\uddff]|' +
'[\u2000-\u206F]|[\u2300-\u27BF]|[\u2B00-\u2BFF]|' +
'[\u3000-\u303F]|[\u3200-\u32FF])'),
- usermention: /^(@(_?)(?:\*\*([^\*]+)\*\*))/, // Match potentially multi-word string between @** **
+ usermention: /^@(_?)(?:\*\*([^\*]+)\*\*)/, // Match potentially multi-word string between @** **
groupmention: /^@(_?)(?:\*([^\*]+)\*)/, // Match multi-word string between @* *
stream_topic: /^#\*\*([^\*>]+)>([^\*]+)\*\*/,
stream: /^#\*\*([^\*]+)\*\*/,
@@ -743,7 +743,7 @@ InlineLexer.prototype.output = function(src) {
// usermention (Zulip)
if (cap = this.rules.usermention.exec(src)) {
src = src.substring(cap[0].length);
- out += this.usermention(unescape(cap[3] || cap[4]), cap[1], cap[2]);
+ out += this.usermention(unescape(cap[2]), cap[0], cap[1]);
continue;
}