diff --git a/components/text.js b/components/text.js index c1b10ebd6..5cf445a9f 100644 --- a/components/text.js +++ b/components/text.js @@ -108,18 +108,22 @@ export default memo(function Text ({ nofollow, imgproxyUrls, children, tab, ...o const renderYoutubeUrl = useCallback((url) => { if (url) { - const regExp = /^https?:\/\/(www\.)?(youtube\.com|youtu\.be)\/(watch\?v=|embed\/)?([^&#\?]+)/; - const match = url.match(regExp); + const regExp = /^https?:\/\/(www\.)?(youtube\.com|youtu\.be)\/(watch\?v=|embed\/)?([^&#?]+)/ + const match = url.match(regExp) if (match && match[4]) { - return ; + return ( + + ) } } - return null; - }, []); + return null + }, []) return (
@@ -146,13 +150,13 @@ export default memo(function Text ({ nofollow, imgproxyUrls, children, tab, ...o const text = children[0] if (!!text && !/^https?:\/\//.test(text)) { // Render video if it's a valid Youtube url, otherwise null - const video = renderYoutubeUrl(href); + const video = renderYoutubeUrl(href) return ( <> {text} {video} - - ); + + ) } // assume the link is an image which will fallback to link if it's not