From 9b0e63d289619140cd5fddeb1aabeabf26869b08 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Wed, 19 Jul 2023 15:51:00 +0800 Subject: [PATCH] Handle elk links --- src/components/status.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/status.jsx b/src/components/status.jsx index 37a1eb59..a12ab8f9 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -1836,7 +1836,12 @@ function _unfurlMastodonLink(instance, url) { console.debug('🦦 Unfurling URL', url); let remoteInstanceFetch; - const urlObj = new URL(url); + let theURL = url; + if (/\/\/elk\.[^\/]+\/[^.]+\.[^.]+/i.test(theURL)) { + // E.g. https://elk.zone/domain.com/@stest/123 -> https://domain.com/@stest/123 + theURL = theURL.replace(/elk\.[^\/]+\//i, ''); + } + const urlObj = new URL(theURL); const domain = urlObj.hostname; const path = urlObj.pathname; // Regex /:username/:id, where username = @username or @username@domain, id = number