From 656f87e3c6a748fbd90f308e6d92a000976d5333 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Sat, 21 Feb 2026 10:30:18 +0500 Subject: [PATCH] editor: fix crash if embed url is invalid or empty --- .../editor/src/extensions/embed/component.tsx | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/editor/src/extensions/embed/component.tsx b/packages/editor/src/extensions/embed/component.tsx index 999c570bf..4dd58422f 100644 --- a/packages/editor/src/extensions/embed/component.tsx +++ b/packages/editor/src/extensions/embed/component.tsx @@ -179,15 +179,19 @@ function getSandboxFeatures(src: string) { } function isYouTubeEmbed(urlString: string) { - const url = new URL(urlString); - return ( - (url.hostname === "www.youtube.com" || - url.hostname === "youtube.com" || - url.hostname === "m.youtube.com" || - url.hostname === "www.youtube-nocookie.com" || - url.hostname === "youtube-nocookie.com") && - url.pathname.startsWith("/embed/") - ); + try { + const url = new URL(urlString); + return ( + (url.hostname === "www.youtube.com" || + url.hostname === "youtube.com" || + url.hostname === "m.youtube.com" || + url.hostname === "www.youtube-nocookie.com" || + url.hostname === "youtube-nocookie.com") && + url.pathname.startsWith("/embed/") + ); + } catch { + return false; + } } function isTwitterX(src: string) {