Fix TypeError due to invalid URL (#1206)

This commit is contained in:
ekzyis 2024-05-29 08:26:42 -05:00 committed by GitHub
parent 738333efa3
commit 30718b9e1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 31 additions and 28 deletions

View File

@ -244,36 +244,39 @@ export default memo(function Text ({ rel, imgproxyUrls, children, tab, itemId, o
paddingRight: '15px' paddingRight: '15px'
} }
const { provider, id, meta } = parseEmbedUrl(href) try {
const { provider, id, meta } = parseEmbedUrl(href)
// Youtube video embed // Youtube video embed
if (provider === 'youtube') { if (provider === 'youtube') {
return ( return (
<div style={videoWrapperStyles}> <div style={videoWrapperStyles}>
<YouTube <YouTube
videoId={id} className={styles.videoContainer} opts={{ videoId={id} className={styles.videoContainer} opts={{
playerVars: { playerVars: {
start: meta?.start || 0 start: meta?.start || 0
} }
}} }}
/>
</div>
)
}
// Rumble video embed
if (provider === 'rumble') {
return (
<div style={videoWrapperStyles}>
<div className={styles.videoContainer}>
<iframe
title='Rumble Video'
allowFullScreen=''
src={meta?.href}
/> />
</div> </div>
</div> )
) }
// Rumble video embed
if (provider === 'rumble') {
return (
<div style={videoWrapperStyles}>
<div className={styles.videoContainer}>
<iframe
title='Rumble Video'
allowFullScreen=''
src={meta?.href}
/>
</div>
</div>
)
}
} catch {
// ignore invalid URLs
} }
// assume the link is an image which will fallback to link if it's not // assume the link is an image which will fallback to link if it's not