We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a68abf2 commit 90d53bbCopy full SHA for 90d53bb
1 file changed
apps/codingcatdev/src/lib/components/content/Video.svelte
@@ -3,11 +3,11 @@
3
export let title: string;
4
5
const youtubeParser = (url: string) => {
6
- var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/;
+ var regExp = /.*(?:youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=)([^#\&\?]*).*/;
7
var match = url.match(regExp);
8
- return match && match[7].length == 11 ? match[7] : false;
+ return match && match[1].length == 11 ? match[1] : false;
9
};
10
-
+ console.log(src);
11
$: finalSrc = `https://www.youtube.com/embed/${youtubeParser(src)}`;
12
</script>
13
0 commit comments