From f73daebb61311efb966afdff75034a7f9c710fbf Mon Sep 17 00:00:00 2001
From: Harrison Healey <harrisonmhealey@gmail.com>
Date: Fri, 22 Apr 2016 14:52:44 -0400
Subject: PLT-1236 Added special handling for markdown links within mattermost
 (#2763)

* Added special handling for markdown links within mattermost

* Moved application of .app__body class to route components
---
 webapp/utils/markdown.jsx | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

(limited to 'webapp/utils/markdown.jsx')

diff --git a/webapp/utils/markdown.jsx b/webapp/utils/markdown.jsx
index dff425e1f..f2b5bcc39 100644
--- a/webapp/utils/markdown.jsx
+++ b/webapp/utils/markdown.jsx
@@ -2,7 +2,6 @@
 // See License.txt for license information.
 
 import * as TextFormatting from './text_formatting.jsx';
-import * as Utils from './utils.jsx';
 import * as syntaxHightlighting from './syntax_hightlighting.jsx';
 
 import marked from 'marked';
@@ -137,18 +136,20 @@ class MattermostMarkdownRenderer extends marked.Renderer {
             outHref = `http://${outHref}`;
         }
 
-        let output = '<a class="theme markdown__link" href="' + outHref + '"';
-        if (title) {
-            output += ' title="' + title + '"';
-        }
+        let output = '<a class="theme markdown__link" ';
 
-        if (outHref.lastIndexOf(Utils.getTeamURLFromAddressBar(), 0) === 0) {
-            output += '>';
+        // special case for links that are inside the app
+        if (outHref.startsWith(global.location.origin)) {
+            output += 'data-link="' + outHref.substring(global.location.origin.length) + '"';
         } else {
-            output += ' target="_blank">';
+            output += 'href="' + outHref + '"';
+        }
+
+        if (title) {
+            output += ' title="' + title + '"';
         }
 
-        output += outText + '</a>';
+        output += '>' + outText + '</a>';
 
         return prefix + output + suffix;
     }
-- 
cgit v1.2.3-1-g7c22

