diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2017-06-02 10:53:03 -0400 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-06-02 10:53:03 -0400 |
commit | e16da499b44a4218834f0d464f0200db2c9db53e (patch) | |
tree | b8e117fd26567b2e25a98bb65941c9d8f39f2695 /webapp/utils | |
parent | 43c440e8a40ebfc4d14c93d636d4c3f1fa6dc606 (diff) | |
download | chat-e16da499b44a4218834f0d464f0200db2c9db53e.tar.gz chat-e16da499b44a4218834f0d464f0200db2c9db53e.tar.bz2 chat-e16da499b44a4218834f0d464f0200db2c9db53e.zip |
PLT-6380 Make team invite links open in the current tab (#6538)
* PLT-6380 Changed link formatting to make team invite links open within the current tab
* Fixed internal link parsing when site URL isn't set
Diffstat (limited to 'webapp/utils')
-rw-r--r-- | webapp/utils/markdown.jsx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/webapp/utils/markdown.jsx b/webapp/utils/markdown.jsx index beba474fc..0d9e977d7 100644 --- a/webapp/utils/markdown.jsx +++ b/webapp/utils/markdown.jsx @@ -200,8 +200,15 @@ class MattermostMarkdownRenderer extends marked.Renderer { output += '" href="' + outHref + '" rel="noreferrer"'; - // special case for channel links and permalinks that are inside the app - if (this.formattingOptions.siteURL && new RegExp('^' + TextFormatting.escapeRegex(this.formattingOptions.siteURL) + '\\/[^\\/]+\\/(pl|channels)\\/').test(outHref)) { + // special case for team invite links, channel links, and permalinks that are inside the app + let internalLink = false; + if (this.formattingOptions.siteURL) { + const pattern = new RegExp('^' + TextFormatting.escapeRegex(this.formattingOptions.siteURL) + '\\/(?:signup_user_complete|[^\\/]+\\/(?:pl|channels))\\/'); + + internalLink = pattern.test(outHref); + } + + if (internalLink) { output += ' data-link="' + outHref.substring(this.formattingOptions.siteURL) + '"'; } else { output += ' target="_blank"'; |