Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
GxqoRR committed Oct 18, 2023
1 parent 8f7a0e4 commit 5a3932d
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions components/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <YouTube videoId={match[4]} className={styles.videoContainer} opts={{
height: '100%',
width: '100%',
}} />;
return (
<YouTube
videoId={match[4]} className={styles.videoContainer} opts={{
height: '100%',
width: '100%'
}}
/>
)
}
}

return null;
}, []);
return null
}, [])

return (
<div className={styles.text}>
Expand All @@ -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 (
<>
<a target='_blank' rel={`noreferrer ${nofollow ? 'nofollow' : ''} noopener`} href={href}>{text}</a>
{video}
</>
);
</>
)
}

// assume the link is an image which will fallback to link if it's not
Expand Down

0 comments on commit 5a3932d

Please sign in to comment.