From cb80dff7df07e9ea9292365fe82fc7af09cc63c1 Mon Sep 17 00:00:00 2001 From: maguroshouta <54607611+maguroshouta@users.noreply.github.com> Date: Tue, 22 Aug 2023 15:56:36 +0900 Subject: [PATCH] =?UTF-8?q?x.com=E3=81=A7=E3=82=82=E5=B1=95=E9=96=8B?= =?UTF-8?q?=E3=81=8C=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=20(#11757)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/components/MkUrlPreview.vue | 2 +- packages/frontend/test/url-preview.test.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/frontend/src/components/MkUrlPreview.vue b/packages/frontend/src/components/MkUrlPreview.vue index 1f9c336eee..bac7f1e310 100644 --- a/packages/frontend/src/components/MkUrlPreview.vue +++ b/packages/frontend/src/components/MkUrlPreview.vue @@ -133,7 +133,7 @@ let unknownUrl = $ref(false); const requestUrl = new URL(props.url); if (!['http:', 'https:'].includes(requestUrl.protocol)) throw new Error('invalid url'); -if (requestUrl.hostname === 'twitter.com' || requestUrl.hostname === 'mobile.twitter.com') { +if (requestUrl.hostname === 'twitter.com' || requestUrl.hostname === 'mobile.twitter.com' || requestUrl.hostname === 'x.com' || requestUrl.hostname === 'mobile.x.com') { const m = requestUrl.pathname.match(/^\/.+\/status(?:es)?\/(\d+)/); if (m) tweetId = m[1]; } diff --git a/packages/frontend/test/url-preview.test.ts b/packages/frontend/test/url-preview.test.ts index b5fcf9bece..0cf3a417e2 100644 --- a/packages/frontend/test/url-preview.test.ts +++ b/packages/frontend/test/url-preview.test.ts @@ -152,4 +152,13 @@ describe('MkUrlPreview', () => { assert.strictEqual(iframe?.getAttribute('allow'), 'fullscreen;web-share'); assert.strictEqual(iframe?.getAttribute('sandbox'), 'allow-popups allow-scripts allow-same-origin'); }); + + test('Loading a post in iframe', async () => { + const iframe = await renderAndOpenPreview({ + url: 'https://x.com/i/web/status/1685072521782325249', + }); + assert.exists(iframe, 'iframe should exist'); + assert.strictEqual(iframe?.getAttribute('allow'), 'fullscreen;web-share'); + assert.strictEqual(iframe?.getAttribute('sandbox'), 'allow-popups allow-scripts allow-same-origin'); + }); });