mirror of
https://github.com/mattermost/mattermost.git
synced 2026-09-24 16:05:00 +08:00
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
This commit is contained in:
committed by
Joram Wilander
parent
43c440e8a4
commit
e16da499b4
@@ -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"';
|
||||
|
||||
Reference in New Issue
Block a user