From 760d26967149d9ac833d9e5ba108836ff8434696 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 3 Feb 2022 08:55:49 +0000 Subject: [PATCH] Fix relative link handling in Element Desktop (#7708) --- src/linkify-matrix.ts | 4 ++-- src/utils/permalinks/Permalinks.ts | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/linkify-matrix.ts b/src/linkify-matrix.ts index fbd27d7b8a..b63ec532f5 100644 --- a/src/linkify-matrix.ts +++ b/src/linkify-matrix.ts @@ -132,9 +132,9 @@ const escapeRegExp = function(string): string { }; // Recognise URLs from both our local and official Element deployments. -// Anyone else really should be using matrix.to. +// Anyone else really should be using matrix.to. vector:// allowed to support Element Desktop relative links. export const ELEMENT_URL_PATTERN = - "^(?:https?://)?(?:" + + "^(?:vector://|https?://)?(?:" + escapeRegExp(window.location.host + window.location.pathname) + "|" + "(?:www\\.)?(?:riot|vector)\\.im/(?:app|beta|staging|develop)/|" + "(?:app|beta|staging|develop)\\.element\\.io/" + diff --git a/src/utils/permalinks/Permalinks.ts b/src/utils/permalinks/Permalinks.ts index ed4844c3ac..51c94c4f75 100644 --- a/src/utils/permalinks/Permalinks.ts +++ b/src/utils/permalinks/Permalinks.ts @@ -362,7 +362,11 @@ export function tryTransformEntityToPermalink(entity: string): string { * @returns {string} The transformed permalink or original URL if unable. */ export function tryTransformPermalinkToLocalHref(permalink: string): string { - if (!permalink.startsWith("http:") && !permalink.startsWith("https:") && !permalink.startsWith("matrix:")) { + if (!permalink.startsWith("http:") && + !permalink.startsWith("https:") && + !permalink.startsWith("matrix:") && + !permalink.startsWith("vector:") // Element Desktop + ) { return permalink; }