Handle elk links

This commit is contained in:
Lim Chee Aun 2023-07-19 15:51:00 +08:00
parent da425b4a70
commit 9b0e63d289

View file

@ -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