From a01c63d9720834ddfc418cad89179fa3c4fda899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BF=E3=81=A6=E3=82=8B=E3=81=9E?= Date: Fri, 13 Feb 2026 12:39:51 +0900 Subject: [PATCH] =?UTF-8?q?PostEmbed=20=E3=81=AE=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E6=80=A7=E5=BC=B7=E5=8C=96=EF=BC=88#130=EF=BC=89=20(#263)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #130 #130 #130 Co-authored-by: miteruzo Reviewed-on: https://git.miteruzo.com/miteruzo/btrc-hub/pulls/263 --- frontend/src/components/PostEmbed.tsx | 28 ++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/PostEmbed.tsx b/frontend/src/components/PostEmbed.tsx index c375ca1..e229666 100644 --- a/frontend/src/components/PostEmbed.tsx +++ b/frontend/src/components/PostEmbed.tsx @@ -18,17 +18,35 @@ export default (({ post }: Props) => { { case 'nicovideo.jp': { - const [videoId] = url.pathname.match (/(?<=\/watch\/)[a-zA-Z0-9]+?(?=\/|$)/)! + const mVideoId = url.pathname.match (/(?<=\/watch\/)[a-zA-Z0-9]+?(?=\/|$)/) + if (!(mVideoId)) + break + + const [videoId] = mVideoId + return } + case 'twitter.com': case 'x.com': - const [userId] = url.pathname.match (/(?<=\/)[^\/]+?(?=\/|$|\?)/)! - const [statusId] = url.pathname.match (/(?<=\/status\/)\d+?(?=\/|$|\?)/)! - return + { + const mUserId = url.pathname.match (/(?<=\/)[^\/]+?(?=\/|$|\?)/) + const mStatusId = url.pathname.match (/(?<=\/status\/)\d+?(?=\/|$|\?)/) + if (!(mUserId) || !(mStatusId)) + break + + const [userId] = mUserId + const [statusId] = mStatusId + + return + } + case 'youtube.com': { - const videoId = url.searchParams.get ('v')! + const videoId = url.searchParams.get ('v') + if (!(videoId)) + break + return (