diff options
author | Vitaly Takmazov | 2023-08-25 09:49:02 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-08-25 10:23:47 +0300 |
commit | 65c5e96c1f4ed987f0631ace8c8af1e394a2eeeb (patch) | |
tree | 5774b307b2e7934a98cb253a85be1f075e1c220a /vnext/src/utils | |
parent | 3441a88c867bebf3b0daa14d4143ae03dd19de59 (diff) |
embed: handle x.com links
Diffstat (limited to 'vnext/src/utils')
-rw-r--r-- | vnext/src/utils/embed.js | 9 |
1 files 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 |