mirror of
https://github.com/younesaassila/ttv-lol-pro.git
synced 2025-05-28 04:20:22 +02:00
fix: types
This commit is contained in:
parent
a7e7aa0e93
commit
f2aee154ba
@ -32,7 +32,7 @@ export default async function onProxyRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const host = getHostFromUrl(details.url);
|
const host = getHostFromUrl(details.url);
|
||||||
if (!host) return { type: "direct" };
|
if (!host) return { type: "DIRECT" };
|
||||||
|
|
||||||
const documentHost = details.documentUrl
|
const documentHost = details.documentUrl
|
||||||
? getHostFromUrl(details.documentUrl)
|
? getHostFromUrl(details.documentUrl)
|
||||||
@ -43,7 +43,7 @@ export default async function onProxyRequest(
|
|||||||
!passportHostRegex.test(documentHost) && // Passport requests have a `passport.twitch.tv` document URL.
|
!passportHostRegex.test(documentHost) && // Passport requests have a `passport.twitch.tv` document URL.
|
||||||
!twitchTvHostRegex.test(documentHost)
|
!twitchTvHostRegex.test(documentHost)
|
||||||
) {
|
) {
|
||||||
return { type: "direct" };
|
return { type: "DIRECT" };
|
||||||
}
|
}
|
||||||
|
|
||||||
const proxies = store.state.optimizedProxiesEnabled
|
const proxies = store.state.optimizedProxiesEnabled
|
||||||
@ -92,12 +92,12 @@ export default async function onProxyRequest(
|
|||||||
if (proxyUsherRequest && usherHostRegex.test(host)) {
|
if (proxyUsherRequest && usherHostRegex.test(host)) {
|
||||||
if (details.url.includes("/vod/")) {
|
if (details.url.includes("/vod/")) {
|
||||||
console.log(`✋ '${details.url}' is a VOD manifest.`);
|
console.log(`✋ '${details.url}' is a VOD manifest.`);
|
||||||
return { type: "direct" };
|
return { type: "DIRECT" };
|
||||||
}
|
}
|
||||||
const channelName = findChannelFromUsherUrl(details.url);
|
const channelName = findChannelFromUsherUrl(details.url);
|
||||||
if (isChannelWhitelisted(channelName)) {
|
if (isChannelWhitelisted(channelName)) {
|
||||||
console.log(`✋ Channel '${channelName}' is whitelisted.`);
|
console.log(`✋ Channel '${channelName}' is whitelisted.`);
|
||||||
return { type: "direct" };
|
return { type: "DIRECT" };
|
||||||
}
|
}
|
||||||
console.log(
|
console.log(
|
||||||
`⌛ Proxying ${details.url} (${
|
`⌛ Proxying ${details.url} (${
|
||||||
@ -119,7 +119,7 @@ export default async function onProxyRequest(
|
|||||||
findChannelFromTwitchTvUrl(tabUrl);
|
findChannelFromTwitchTvUrl(tabUrl);
|
||||||
if (isChannelWhitelisted(channelName)) {
|
if (isChannelWhitelisted(channelName)) {
|
||||||
console.log(`✋ Channel '${channelName}' is whitelisted.`);
|
console.log(`✋ Channel '${channelName}' is whitelisted.`);
|
||||||
return { type: "direct" };
|
return { type: "DIRECT" };
|
||||||
}
|
}
|
||||||
console.log(
|
console.log(
|
||||||
`⌛ Proxying ${details.url} (${
|
`⌛ Proxying ${details.url} (${
|
||||||
@ -149,12 +149,12 @@ export default async function onProxyRequest(
|
|||||||
return proxyInfoArray;
|
return proxyInfoArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { type: "direct" };
|
return { type: "DIRECT" };
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProxyInfoArrayFromUrls(urls: string[]): ProxyInfo[] {
|
function getProxyInfoArrayFromUrls(urls: string[]): ProxyInfo[] {
|
||||||
return [
|
return [
|
||||||
...urls.map(getProxyInfoFromUrl),
|
...urls.map(getProxyInfoFromUrl),
|
||||||
{ type: "direct" } as ProxyInfo, // Fallback to direct connection if all proxies fail.
|
{ type: "DIRECT" } as ProxyInfo, // Fallback to direct connection if all proxies fail.
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -27,12 +27,12 @@ const defaultPorts: Partial<{
|
|||||||
export function getProxyInfoFromUrl(url: string) {
|
export function getProxyInfoFromUrl(url: string) {
|
||||||
let protocol = "";
|
let protocol = "";
|
||||||
if (url.includes("://")) {
|
if (url.includes("://")) {
|
||||||
let [_protocol, urlWithoutProtocol] = url.split("://");
|
const [_protocol, urlWithoutProtocol] = url.split("://");
|
||||||
protocol = _protocol;
|
protocol = _protocol;
|
||||||
url = urlWithoutProtocol;
|
url = urlWithoutProtocol;
|
||||||
}
|
}
|
||||||
const lastIndexOfAt = url.lastIndexOf("@");
|
const lastIndexOfAt = url.lastIndexOf("@");
|
||||||
let hostname = url.substring(lastIndexOfAt + 1, url.length);
|
const hostname = url.substring(lastIndexOfAt + 1, url.length);
|
||||||
const lastIndexOfColon = getLastIndexOfColon(hostname);
|
const lastIndexOfColon = getLastIndexOfColon(hostname);
|
||||||
|
|
||||||
let host: string | undefined = undefined;
|
let host: string | undefined = undefined;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user