[+] Encapsulate function to get vid from youtube url

This commit is contained in:
Hykilpikonna
2019-12-25 17:25:13 -05:00
parent 1fcd4c23ea
commit 94fd6a5c0d
+16
View File
@@ -172,3 +172,19 @@ export default class App extends Vue
this.$refs.ps.show(this.swipeItems(), {index: index});
}
}
/**
* Get VID from youtube url
*
* @param url
*/
function getYoutubeVID(url: string)
{
let video_id = url.split('v=')[1];
let ampersandPosition = video_id.indexOf('&');
if(ampersandPosition != -1)
{
video_id = video_id.substring(0, ampersandPosition);
}
return video_id;
}