summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--webapp/utils/markdown.jsx6
-rw-r--r--webapp/utils/text_formatting.jsx2
2 files changed, 4 insertions, 4 deletions
diff --git a/webapp/utils/markdown.jsx b/webapp/utils/markdown.jsx
index e291ce546..028e667fd 100644
--- a/webapp/utils/markdown.jsx
+++ b/webapp/utils/markdown.jsx
@@ -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"';
}
diff --git a/webapp/utils/text_formatting.jsx b/webapp/utils/text_formatting.jsx
index b304fa75a..655b4180e 100644
--- a/webapp/utils/text_formatting.jsx
+++ b/webapp/utils/text_formatting.jsx
@@ -199,7 +199,7 @@ function autolinkAtMentions(text, tokens) {
return output;
}
-function escapeRegex(text) {
+export function escapeRegex(text) {
return text.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
}