PLT-3534 Changed special handling of internal links to only occur for permalinks and links to channels (#3731)

Этот коммит содержится в:
Harrison Healey
2016-08-03 19:28:38 -04:00
коммит произвёл enahum
родитель 7b211f93a0
Коммит c79685b0bc
2 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@@ -151,9 +151,9 @@ class MattermostMarkdownRenderer extends marked.Renderer {
let output = '<a class="theme markdown__link" href="' + outHref + '" rel="noreferrer"'; let output = '<a class="theme markdown__link" href="' + outHref + '" rel="noreferrer"';
// special case for links that are inside the app // special case for channel links and permalinks that are inside the app
if (outHref.startsWith(global.location.origin)) { if (new RegExp('^' + TextFormatting.escapeRegex(global.mm_config.SiteURL) + '\\/[^\\/]+\\/(pl|channels)\\/').test(outHref)) {
output += ' data-link="' + outHref.substring(global.location.origin.length) + '"'; output += ' data-link="' + outHref.substring(global.mm_config.SiteURL.length) + '"';
} else { } else {
output += ' target="_blank"'; output += ' target="_blank"';
} }

Просмотреть файл

@@ -199,7 +199,7 @@ function autolinkAtMentions(text, tokens) {
return output; return output;
} }
function escapeRegex(text) { export function escapeRegex(text) {
return text.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); return text.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
} }