mirror of
https://github.com/younesaassila/ttv-lol-pro.git
synced 2025-04-29 22:14:27 +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);
|
||||
if (!host) return { type: "direct" };
|
||||
if (!host) return { type: "DIRECT" };
|
||||
|
||||
const documentHost = 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.
|
||||
!twitchTvHostRegex.test(documentHost)
|
||||
) {
|
||||
return { type: "direct" };
|
||||
return { type: "DIRECT" };
|
||||
}
|
||||
|
||||
const proxies = store.state.optimizedProxiesEnabled
|
||||
@ -92,12 +92,12 @@ export default async function onProxyRequest(
|
||||
if (proxyUsherRequest && usherHostRegex.test(host)) {
|
||||
if (details.url.includes("/vod/")) {
|
||||
console.log(`✋ '${details.url}' is a VOD manifest.`);
|
||||
return { type: "direct" };
|
||||
return { type: "DIRECT" };
|
||||
}
|
||||
const channelName = findChannelFromUsherUrl(details.url);
|
||||
if (isChannelWhitelisted(channelName)) {
|
||||
console.log(`✋ Channel '${channelName}' is whitelisted.`);
|
||||
return { type: "direct" };
|
||||
return { type: "DIRECT" };
|
||||
}
|
||||
console.log(
|
||||
`⌛ Proxying ${details.url} (${
|
||||
@ -119,7 +119,7 @@ export default async function onProxyRequest(
|
||||
findChannelFromTwitchTvUrl(tabUrl);
|
||||
if (isChannelWhitelisted(channelName)) {
|
||||
console.log(`✋ Channel '${channelName}' is whitelisted.`);
|
||||
return { type: "direct" };
|
||||
return { type: "DIRECT" };
|
||||
}
|
||||
console.log(
|
||||
`⌛ Proxying ${details.url} (${
|
||||
@ -149,12 +149,12 @@ export default async function onProxyRequest(
|
||||
return proxyInfoArray;
|
||||
}
|
||||
|
||||
return { type: "direct" };
|
||||
return { type: "DIRECT" };
|
||||
}
|
||||
|
||||
function getProxyInfoArrayFromUrls(urls: string[]): ProxyInfo[] {
|
||||
return [
|
||||
...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) {
|
||||
let protocol = "";
|
||||
if (url.includes("://")) {
|
||||
let [_protocol, urlWithoutProtocol] = url.split("://");
|
||||
const [_protocol, urlWithoutProtocol] = url.split("://");
|
||||
protocol = _protocol;
|
||||
url = urlWithoutProtocol;
|
||||
}
|
||||
const lastIndexOfAt = url.lastIndexOf("@");
|
||||
let hostname = url.substring(lastIndexOfAt + 1, url.length);
|
||||
const hostname = url.substring(lastIndexOfAt + 1, url.length);
|
||||
const lastIndexOfColon = getLastIndexOfColon(hostname);
|
||||
|
||||
let host: string | undefined = undefined;
|
||||
|
Loading…
x
Reference in New Issue
Block a user