[bugfix,site][s]: YOUTUBE_REGEX was matching other urls so fixed by just using YOUTUBE_ID_REGEX - fixes #186.

NB: probably can replace YOUTUBE_REGEX everywhere.
This commit is contained in:
Rufus Pollock 2022-06-21 12:17:03 +02:00
parent 09fcb2d112
commit 2bd98407d2
1 changed files with 2 additions and 2 deletions

View File

@ -1,6 +1,6 @@
import LiteYouTubeEmbed from "react-lite-youtube-embed";
import TwitterEmbed from "./TwitterEmbed";
import { YOUTUBE_REGEX, TWITTER_REGEX, YOUTUBE_ID_REGEX } from "../lib/constants";
import { TWITTER_REGEX, YOUTUBE_ID_REGEX } from "../lib/constants";
export const Paragraph = (props) => {
if (
@ -10,7 +10,7 @@ export const Paragraph = (props) => {
) {
const href = props.children.props.href
if (YOUTUBE_REGEX.test(href)) {
if (YOUTUBE_ID_REGEX.test(href)) {
const youtubeId = href.match(YOUTUBE_ID_REGEX)[1];
let startTime = href.match(/t=[0-9]*/)
if (startTime) startTime = startTime[0].split("=").pop()