From 65c5e96c1f4ed987f0631ace8c8af1e394a2eeeb Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 25 Aug 2023 09:49:02 +0300 Subject: embed: handle x.com links --- vnext/src/utils/embed.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vnext/src/utils/embed.js b/vnext/src/utils/embed.js index 3020058a..514ce1ce 100644 --- a/vnext/src/utils/embed.js +++ b/vnext/src/utils/embed.js @@ -268,9 +268,14 @@ function getEmbeddableLinkTypes() { name: 'Twitter', id: 'embed_twitter_status', className: 'twi compact', - re: /^(?:https?:)?\/\/(?:www\.)?(?:mobile\.)?twitter\.com\/([\w-]+)\/status(?:es)?\/([\d]+)/i, + re: /^(?:https?:)?\/\/(?:www\.)?(?:mobile\.)?(twitter|x)\.com\/([\w-]+)\/status(?:es)?\/([\d]+)/i, makeNode: function(aNode, reResult, div) { - fetch('https://x.juick.com/oembed?url=' + reResult[0]) + const wrong_prefix = 'https://x.com' + const correct_prefix = 'https://twitter.com' + const twitter_url = reResult[0].startsWith(wrong_prefix) ? + reResult[0].replace(wrong_prefix, correct_prefix) + : reResult[0] + fetch('https://x.juick.com/oembed?url=' + twitter_url) .then(response => response.json()) .then(json => { div.innerHTML = json.html -- cgit v1.2.3