diff --git a/src/matrix-to.js b/src/matrix-to.js index d997be12f9..c9040e04af 100644 --- a/src/matrix-to.js +++ b/src/matrix-to.js @@ -260,12 +260,7 @@ function getServerName(userId) { function getHostnameFromMatrixDomain(domain) { if (!domain) return null; - - // The hostname might have a port, so we convert it to a URL and - // split out the real hostname. - const parser = document.createElement('a'); - parser.href = "https://" + domain; - return parser.hostname; + return new URL(`https://${domain}`).hostname; } function isHostInRegex(hostname, regexps) {