Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Fix relative link handling in Element Desktop (#7708)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Feb 3, 2022
1 parent f0446a2 commit 760d269
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/linkify-matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/" +
Expand Down
6 changes: 5 additions & 1 deletion src/utils/permalinks/Permalinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 760d269

Please sign in to comment.