s
This commit is contained in:
@@ -13,6 +13,16 @@ export type YoutubeProChannel = {
|
||||
};
|
||||
|
||||
const STORAGE_KEY = "live-hub-youtube-pro-v2";
|
||||
const PM2_SANITIZE_RE = /[^a-zA-Z0-9_.-]+/g;
|
||||
|
||||
export function sanitizeYoutubePm2Name(value: string): string {
|
||||
return (value || "").trim().replace(PM2_SANITIZE_RE, "_");
|
||||
}
|
||||
|
||||
export function resolveYoutubeProChannelPm2(channel: Pick<YoutubeProChannel, "id" | "pm2Name">): string {
|
||||
const raw = sanitizeYoutubePm2Name(String(channel.pm2Name || ""));
|
||||
return raw || defaultPm2NameForChannel(String(channel.id || ""));
|
||||
}
|
||||
|
||||
export function parseYoutubeProChannelList(raw: unknown): YoutubeProChannel[] {
|
||||
if (!Array.isArray(raw)) return [];
|
||||
@@ -116,5 +126,5 @@ export function newChannelId(): string {
|
||||
}
|
||||
|
||||
export function defaultPm2NameForChannel(channelId: string): string {
|
||||
return `youtube2__${channelId}`;
|
||||
return `youtube2__${sanitizeYoutubePm2Name(channelId) || "channel"}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user