From fe6156302d639eb2313968cfa9ad251af76886fe Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Tue, 12 Nov 2024 17:07:38 +0200 Subject: [PATCH] web/timeline: decode matrix uris when clicking --- web/src/ui/timeline/content/TextMessageBody.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/web/src/ui/timeline/content/TextMessageBody.tsx b/web/src/ui/timeline/content/TextMessageBody.tsx index ab5ad64..53c6090 100644 --- a/web/src/ui/timeline/content/TextMessageBody.tsx +++ b/web/src/ui/timeline/content/TextMessageBody.tsx @@ -27,18 +27,19 @@ function isAnchorElement(elem: EventTarget): elem is HTMLAnchorElement { function onClickMatrixURI(href: string) { const url = new URL(href) const pathParts = url.pathname.split("/") + const decodedPart = decodeURIComponent(pathParts[1]) switch (pathParts[0]) { case "u": return window.mainScreenContext.setRightPanel({ type: "user", - userID: pathParts[1], + userID: `@${decodedPart}`, }) case "roomid": - return window.mainScreenContext.setActiveRoom(pathParts[1]) + return window.mainScreenContext.setActiveRoom(`!${decodedPart}`) case "r": - return window.client.rpc.resolveAlias(`#${pathParts[1]}`).then( + return window.client.rpc.resolveAlias(`#${decodedPart}`).then( res => window.mainScreenContext.setActiveRoom(res.room_id), - err => window.alert(`Failed to resolve room alias #${pathParts[1]}: ${err}`), + err => window.alert(`Failed to resolve room alias #${decodedPart}: ${err}`), ) } }