From 2bb7aec0de2bb255d17a849c855072358882b009 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 7 Nov 2016 10:57:08 +0000 Subject: [PATCH 1/2] Don't do URL previews for matrix.to --- src/components/views/messages/TextualBody.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/views/messages/TextualBody.js b/src/components/views/messages/TextualBody.js index 04a3a83fd7..a5219ab00e 100644 --- a/src/components/views/messages/TextualBody.js +++ b/src/components/views/messages/TextualBody.js @@ -162,6 +162,12 @@ module.exports = React.createClass({ else { var url = node.getAttribute("href"); var host = url.match(/^https?:\/\/(.*?)(\/|$)/)[1]; + + // never preview matrix.to links (if anything we should give a smart + // preview of the room/user they point to: nobody needs to be reminded + // what the matrix.to site looks like). + if (host == 'matrix.to') return false; + if (node.textContent.toLowerCase().trim().startsWith(host.toLowerCase())) { // it's a "foo.pl" style link return; From 5c2c01d414ba7379fca68d3f056a6813e763197a Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 7 Nov 2016 11:45:55 +0000 Subject: [PATCH 2/2] Fix function to consistently return boolean --- src/components/views/messages/TextualBody.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/views/messages/TextualBody.js b/src/components/views/messages/TextualBody.js index a5219ab00e..7540d40dc2 100644 --- a/src/components/views/messages/TextualBody.js +++ b/src/components/views/messages/TextualBody.js @@ -157,7 +157,7 @@ module.exports = React.createClass({ // TODO: make this configurable? if (node.textContent.indexOf("/") > -1) { - return node; + return true; } else { var url = node.getAttribute("href"); @@ -170,11 +170,11 @@ module.exports = React.createClass({ if (node.textContent.toLowerCase().trim().startsWith(host.toLowerCase())) { // it's a "foo.pl" style link - return; + return false; } else { // it's a [foo bar](http://foo.com) style link - return node; + return true; } } },