fix(embed): reddit links have to include '/comments/' to be embeddable

This commit is contained in:
Tom (plebeius.eth)
2024-10-20 17:59:47 +02:00
parent e9f7f1bd20
commit 5e6c9fba7e
+5
View File
@@ -306,6 +306,11 @@ const canEmbedHosts = new Set<string>([
]);
export const canEmbed = (parsedUrl: URL): boolean => {
if (redditHosts.has(parsedUrl.host)) {
// Reddit posts are not embeddable if the URL does not include '/comments/'
return parsedUrl.pathname.includes('/comments/');
}
return canEmbedHosts.has(parsedUrl.host) || (parsedUrl.host.startsWith('yt.') && parsedUrl.searchParams.has('v'));
};