From e16da499b44a4218834f0d464f0200db2c9db53e Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Fri, 2 Jun 2017 10:53:03 -0400 Subject: 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 --- webapp/utils/markdown.jsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'webapp') 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"'; -- cgit v1.2.3-1-g7c22