fix: YouTube links with timestamp cannot be embedded, closes #5051
This commit is contained in:
@@ -5,17 +5,21 @@ import { EmbedProps as Props } from ".";
|
|||||||
function YouTube(props: Props) {
|
function YouTube(props: Props) {
|
||||||
const { matches } = props.attrs;
|
const { matches } = props.attrs;
|
||||||
const videoId = matches[1];
|
const videoId = matches[1];
|
||||||
|
const queryParameters = matches[2];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Frame
|
<Frame
|
||||||
{...props}
|
{...props}
|
||||||
src={`https://www.youtube.com/embed/${videoId}?modestbranding=1`}
|
src={`https://www.youtube.com/embed/${videoId}?modestbranding=1${
|
||||||
|
queryParameters ? `&${queryParameters}` : ""
|
||||||
|
}`}
|
||||||
title={`YouTube (${videoId})`}
|
title={`YouTube (${videoId})`}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
YouTube.ENABLED = [
|
YouTube.ENABLED = [
|
||||||
/(?:https?:\/\/)?(?:www\.)?youtu\.?be(?:\.com)?\/?.*(?:watch|embed)?(?:.*v=|v\/|\/)([a-zA-Z0-9_-]{11})$/i,
|
/(?:https?:\/\/)?(?:www\.)?youtu\.?be(?:\.com)?\/?.*(?:watch|embed)?(?:.*v=|v\/|\/)([a-zA-Z0-9_-]{11})(?:\?)?(.*)?$/i,
|
||||||
];
|
];
|
||||||
|
|
||||||
export default YouTube;
|
export default YouTube;
|
||||||
|
|||||||
Reference in New Issue
Block a user