From cbab1dcfb47117e25d025a9ae12abe108bd36ae8 Mon Sep 17 00:00:00 2001 From: philltran Date: Tue, 9 Jun 2026 01:43:34 -0400 Subject: [PATCH] Add x.com URL support and update Twitter provider endpoint - Extend patterns to match both twitter.com and x.com post URLs - Normalize x.com URLs to twitter.com before proxying (publish.x.com/oembed is unreliable for x.com-domain input; workaround used by WordPress, Umbraco, Ghost, and Rocket.Chat) - Update oEmbed endpoint to canonical https://publish.x.com/oembed - Rename provider to "X (formerly Twitter)" --- lib/Noembed/Provider/Twitter.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Noembed/Provider/Twitter.pm b/lib/Noembed/Provider/Twitter.pm index 2dfbb88..babdc42 100644 --- a/lib/Noembed/Provider/Twitter.pm +++ b/lib/Noembed/Provider/Twitter.pm @@ -2,16 +2,18 @@ package Noembed::Provider::Twitter; use parent 'Noembed::oEmbedProvider'; -sub patterns { 'https?://(?:www|mobile\.)?twitter\.com/(?:#!/)?([^/]+)/status(?:es)?/(\d+)' } +# Matches both twitter.com and x.com post URLs (including mobile and hash-bang variants) +sub patterns { 'https?://(?:www|mobile\.)?(?:twitter|x)\.com/(?:#!/)?([^/]+)/status(?:es)?/(\d+)' } sub build_url { my ($self, $req) = @_; my $captures = $req->captures; + # Normalize to twitter.com — publish.x.com/oembed does not reliably resolve x.com-domain URLs $req->url(sprintf "https://twitter.com/%s/status/%s", @$captures); $self->SUPER::build_url($req); } -sub provider_name { "Twitter" } -sub oembed_url { "https://publish.twitter.com/oembed" } +sub provider_name { "X (formerly Twitter)" } +sub oembed_url { "https://publish.x.com/oembed" } 1;