From b8c80c6d9520ec0af0407c576ee565df85fcc41f Mon Sep 17 00:00:00 2001 From: Florian Orben Date: Wed, 14 Oct 2015 20:21:25 +0200 Subject: Don't auto-add http:// to mailto: and ftp: markdown links --- web/react/utils/markdown.jsx | 2 +- web/react/utils/text_formatting.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'web/react/utils') diff --git a/web/react/utils/markdown.jsx b/web/react/utils/markdown.jsx index 12d6dd424..2813798d2 100644 --- a/web/react/utils/markdown.jsx +++ b/web/react/utils/markdown.jsx @@ -32,7 +32,7 @@ export class MattermostMarkdownRenderer extends marked.Renderer { link(href, title, text) { let outHref = href; - if (outHref.lastIndexOf('http', 0) !== 0) { + if (!(/^(mailto|https?|ftp)/.test(outHref))) { outHref = `http://${outHref}`; } diff --git a/web/react/utils/text_formatting.jsx b/web/react/utils/text_formatting.jsx index 2b6e6e14e..d79aeed68 100644 --- a/web/react/utils/text_formatting.jsx +++ b/web/react/utils/text_formatting.jsx @@ -89,7 +89,7 @@ function autolinkUrls(text, tokens) { if (match.getType() === 'email') { url = `mailto:${url}`; - } else if (url.lastIndexOf('http', 0) !== 0) { + } else if (!(/^(mailto|https?|ftp)/.test(url))) { url = `http://${url}`; } -- cgit v1.2.3-1-g7c22