diff --git a/src/HtmlUtils.js b/src/HtmlUtils.js index 18de137634..3dc463a3d7 100644 --- a/src/HtmlUtils.js +++ b/src/HtmlUtils.js @@ -47,12 +47,12 @@ var sanitizeHtmlParams = { transformTags: { // custom to matrix // add blank targets to all hyperlinks except vector URLs 'a': function(tagName, attribs) { - var m = attribs.href.match(linkifyMatrix.VECTOR_URL_PATTERN); + var m = attribs.href ? attribs.href.match(linkifyMatrix.VECTOR_URL_PATTERN) : null; if (m) { - return { tagName: 'a', attribs: { href: attribs.href } }; + return { tagName: 'a', attribs: { href: attribs.href, name: attribs.name } }; } else { - return { tagName: 'a', attribs: { href: attribs.href, target: '_blank'} }; + return { tagName: 'a', attribs: { href: attribs.href, name: attribs.name, target: '_blank' } }; } }, }, diff --git a/src/linkify-matrix.js b/src/linkify-matrix.js index bb9b7d5c81..a12ef8eaf5 100644 --- a/src/linkify-matrix.js +++ b/src/linkify-matrix.js @@ -106,7 +106,7 @@ var escapeRegExp = function(string) { // as if someone explicitly links to vector.im/develop and we're on vector.im/beta // they may well be trying to get us to explicitly go to develop. // FIXME: intercept matrix.to URLs as well. -matrixLinkify.VECTOR_URL_PATTERN = "(https?:\/\/)?" + escapeRegExp(window.location.host + window.location.pathname); +matrixLinkify.VECTOR_URL_PATTERN = "^(https?:\/\/)?" + escapeRegExp(window.location.host + window.location.pathname); matrixLinkify.options = { events: function (href, type) { @@ -146,9 +146,7 @@ matrixLinkify.options = { return '_blank'; } } - else { - return '_blank'; - } + return null; }, };