refactor(channelRequest): Added new type of channel url - /@examplechannel.

This commit is contained in:
Georgiy 2023-05-26 18:45:54 +03:00
parent e2db406b90
commit 90931d7286
1 changed files with 11 additions and 5 deletions

View File

@ -6,7 +6,7 @@ const getDefaultState = () => {
banner: null, banner: null,
title: null, title: null,
subscribe: null, subscribe: null,
subscribeAlt: null, subscribeAlt: "",
descriptionPreview: null, descriptionPreview: null,
subscribers: null, subscribers: null,
videosCount: null, videosCount: null,
@ -22,12 +22,18 @@ export const actions = {
Object.assign(state, getDefaultState()); Object.assign(state, getDefaultState());
state.loading = true; state.loading = true;
console.log(channelUrl); console.log(channelUrl);
const channelRequest = let channelRequest = "";
console.warn(channelUrl);
if (
channelUrl.includes("/c/") || channelUrl.includes("/c/") ||
channelUrl.includes("/user/") || channelUrl.includes("/user/") ||
channelUrl.includes("/channel/") channelUrl.includes("/channel/") ||
? `https://youtube.com/${channelUrl}` channelUrl.includes("/@")
: `https://youtube.com/channel/${channelUrl}`; ) {
channelRequest = `https://youtube.com/${channelUrl}`;
} else {
channelRequest = `https://youtube.com/channel/${channelUrl}`;
}
this.$youtube this.$youtube
.getChannel(channelRequest) .getChannel(channelRequest)
.then((channel) => { .then((channel) => {