diff --git a/.changeset/add_shorts_support_to_fix_crash.md b/.changeset/add_shorts_support_to_fix_crash.md new file mode 100644 index 000000000..a7396c050 --- /dev/null +++ b/.changeset/add_shorts_support_to_fix_crash.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Add youtube shorts support to stop it from crashing sable. diff --git a/src/app/components/url-preview/ClientPreview.tsx b/src/app/components/url-preview/ClientPreview.tsx index fa35b880d..948f48095 100644 --- a/src/app/components/url-preview/ClientPreview.tsx +++ b/src/app/components/url-preview/ClientPreview.tsx @@ -167,10 +167,14 @@ function parseYoutubeLink(url: string): YoutubeLink | null { const split = path.split('?'); [videoId] = split; params = split[1]?.split('&'); - } else { + } else if (url.includes('/shorts/')) { + const split = path.split('/shorts/'); + [videoId] = split; + params = split[1]?.split('shorts'); + } else if (url.includes('youtube.com')) { params = path.split('?')[1].split('&'); videoId = params.find((s) => s.startsWith('v='), params)?.split('v=')[1]; - } + } else return null; if (!videoId) return null;