mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
PLT-3534 Changed special handling of internal links to only occur for permalinks and links to channels (#3731)
This commit is contained in:
@@ -151,9 +151,9 @@ class MattermostMarkdownRenderer extends marked.Renderer {
|
||||
|
||||
let output = '<a class="theme markdown__link" href="' + outHref + '" rel="noreferrer"';
|
||||
|
||||
// special case for links that are inside the app
|
||||
if (outHref.startsWith(global.location.origin)) {
|
||||
output += ' data-link="' + outHref.substring(global.location.origin.length) + '"';
|
||||
// special case for channel links and permalinks that are inside the app
|
||||
if (new RegExp('^' + TextFormatting.escapeRegex(global.mm_config.SiteURL) + '\\/[^\\/]+\\/(pl|channels)\\/').test(outHref)) {
|
||||
output += ' data-link="' + outHref.substring(global.mm_config.SiteURL.length) + '"';
|
||||
} else {
|
||||
output += ' target="_blank"';
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ function autolinkAtMentions(text, tokens) {
|
||||
return output;
|
||||
}
|
||||
|
||||
function escapeRegex(text) {
|
||||
export function escapeRegex(text) {
|
||||
return text.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user