mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-11-10 10:18:23 +00:00
parent
34b4d608c5
commit
5061a4ac0a
@ -81,9 +81,11 @@ export default {
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
if (this.handleRedirect()) return;
|
||||
this.updateResults();
|
||||
},
|
||||
activated() {
|
||||
this.handleRedirect();
|
||||
window.addEventListener("scroll", this.handleScroll);
|
||||
},
|
||||
deactivated() {
|
||||
@ -122,6 +124,18 @@ export default {
|
||||
shouldUseVideoItem(item) {
|
||||
return item.title;
|
||||
},
|
||||
handleRedirect() {
|
||||
const query = this.$route.query.search_query;
|
||||
const url =
|
||||
/(?:http(?:s)?:\/\/)?(?:www\.)?youtube\.com(\/[/a-zA-Z0-9?=&]*)/gm.exec(query)?.[1] ??
|
||||
/(?:http(?:s)?:\/\/)?(?:www\.)?youtu\.be\/(?:watch\?v=)?([/a-zA-Z0-9?=&]*)/gm
|
||||
.exec(query)?.[1]
|
||||
.replace(/^/, "/watch?v=");
|
||||
if (url) {
|
||||
this.$router.push(url);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user