From 90fb84d8bfe4d6ee87fe14fddcce1d04932d073c Mon Sep 17 00:00:00 2001 From: orbachar <57751360+orbachar@users.noreply.github.com> Date: Thu, 20 Nov 2025 08:35:13 +0000 Subject: [PATCH 1/3] Fix Twitter/X.com embed URLs with query parameters and path segments - Updated regex to properly handle URLs with query parameters (e.g., ?s=20) - Updated regex to properly handle URLs with path segments after status ID (e.g., /photo/1) - Added test cases for x.com URLs with query parameters and path segments - Fixes issue where https://x.com URLs with additional parameters were not recognized --- src/services.ts | 2 +- test/services.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/services.ts b/src/services.ts index 9bc5e49a..bfe1b147 100644 --- a/src/services.ts +++ b/src/services.ts @@ -140,7 +140,7 @@ const SERVICES: ServicesConfigType = { id: (groups: string[]) => groups?.[0]?.split("/")[0], }, twitter: { - regex: /^https?:\/\/(www\.)?(?:twitter\.com|x\.com)\/.+\/status\/(\d+)/, + regex: /^https?:\/\/(www\.)?(?:twitter\.com|x\.com)\/.+\/status\/(\d+)(?:\?.*)?$/, embedUrl: 'https://platform.twitter.com/embed/Tweet.html?id=<%= remote_id %>', html: '', height: 300, diff --git a/test/services.ts b/test/services.ts index 6072671a..b6d2b4ae 100644 --- a/test/services.ts +++ b/test/services.ts @@ -264,6 +264,18 @@ describe('Services Regexps', () => { source: 'https://x.com/codex_team/status/1202295536826630145', embed: 'https://platform.twitter.com/embed/Tweet.html?id=1202295536826630145' }, + { + source: 'https://x.com/MrShibolet/status/1990842843481387410', + embed: 'https://platform.twitter.com/embed/Tweet.html?id=1990842843481387410' + }, + { + source: 'https://x.com/MrShibolet/status/1990842843481387410?s=20', + embed: 'https://platform.twitter.com/embed/Tweet.html?id=1990842843481387410' + }, + { + source: 'https://x.com/cb_doge/status/1817235892916146413/photo/1', + embed: 'https://platform.twitter.com/embed/Tweet.html?id=1817235892916146413' + }, ]; urls.forEach(url => { From ea3bd3cd4adb230060ad6959970c15e34467b364 Mon Sep 17 00:00:00 2001 From: orbachar <57751360+orbachar@users.noreply.github.com> Date: Thu, 20 Nov 2025 08:37:53 +0000 Subject: [PATCH 2/3] Fix regex to properly support path segments like /photo/1 The previous regex only handled query parameters but not path segments. Updated to: /^https?:\/\/(www\.)?(?:twitter\.com|x\.com)\/.+\/status\/(\d+)(?:\/.*)?(?:\?.*)?$/ This now properly matches: - https://x.com/cb_doge/status/1817235892916146413/photo/1 - https://x.com/status/123?s=20 - https://x.com/status/123/photo/1?s=20 --- src/services.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services.ts b/src/services.ts index bfe1b147..ceacf4b9 100644 --- a/src/services.ts +++ b/src/services.ts @@ -140,7 +140,7 @@ const SERVICES: ServicesConfigType = { id: (groups: string[]) => groups?.[0]?.split("/")[0], }, twitter: { - regex: /^https?:\/\/(www\.)?(?:twitter\.com|x\.com)\/.+\/status\/(\d+)(?:\?.*)?$/, + regex: /^https?:\/\/(www\.)?(?:twitter\.com|x\.com)\/.+\/status\/(\d+)(?:\/.*)?(?:\?.*)?$/, embedUrl: 'https://platform.twitter.com/embed/Tweet.html?id=<%= remote_id %>', html: '', height: 300, From b2d960c140261c13b32de59ca5e0bfee9c9ae939 Mon Sep 17 00:00:00 2001 From: orbachar <57751360+orbachar@users.noreply.github.com> Date: Thu, 20 Nov 2025 08:41:02 +0000 Subject: [PATCH 3/3] Fix regex for Twitter/X.com URLs to support path segments without query parameters --- src/services.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services.ts b/src/services.ts index ceacf4b9..63f7bb8b 100644 --- a/src/services.ts +++ b/src/services.ts @@ -140,7 +140,7 @@ const SERVICES: ServicesConfigType = { id: (groups: string[]) => groups?.[0]?.split("/")[0], }, twitter: { - regex: /^https?:\/\/(www\.)?(?:twitter\.com|x\.com)\/.+\/status\/(\d+)(?:\/.*)?(?:\?.*)?$/, + regex: /^https?:\/\/(www\.)?(?:twitter\.com|x\.com)\/.+\/status\/(\d+)(?:\/[^?]*)?(?:\?.*)?$/, embedUrl: 'https://platform.twitter.com/embed/Tweet.html?id=<%= remote_id %>', html: '', height: 300,