mirror of
https://github.com/younesaassila/ttv-lol-pro.git
synced 2025-04-29 22:14:27 +02:00
Improve code
This commit is contained in:
parent
de97812b24
commit
6df1cc7638
@ -14,9 +14,9 @@ export function getProxyInfoFromUrl(
|
||||
): ProxyInfo & { host: string; port: number } {
|
||||
let type: ProxyType | undefined = undefined;
|
||||
if (url.includes("://")) {
|
||||
const [protocol, urlWithoutProtocol] = url.split("://", 2);
|
||||
const [protocol] = url.split("://", 1);
|
||||
type = protocol as ProxyType;
|
||||
url = urlWithoutProtocol;
|
||||
url = url.substring(protocol.length + 3, url.length);
|
||||
}
|
||||
|
||||
const lastIndexOfAt = url.lastIndexOf("@");
|
||||
|
@ -15,8 +15,8 @@ const PROXY_TYPE_MAP: Readonly<Record<ProxyType, string>> = Object.freeze({
|
||||
direct: "DIRECT",
|
||||
http: "PROXY",
|
||||
https: "HTTPS",
|
||||
socks4: "SOCKS4",
|
||||
socks: "SOCKS5",
|
||||
socks4: "SOCKS4",
|
||||
});
|
||||
|
||||
export function updateProxySettings(requestFilter?: ProxyRequestType[]) {
|
||||
|
@ -346,13 +346,13 @@ function isOptimizedProxyUrlAllowed(url: string): AllowedResult {
|
||||
}
|
||||
|
||||
if (url.includes("://")) {
|
||||
const [protocol, urlWithoutProtocol] = url.split("://", 2);
|
||||
const [protocol] = url.split("://", 1);
|
||||
if (!store.state.allowOtherProxyProtocols) {
|
||||
return [false, "Proxy URLs must not contain a protocol (e.g. 'http://')"];
|
||||
} else if (!["http", "https", "socks", "socks4"].includes(protocol)) {
|
||||
return [false, `'${protocol}' is not a supported protocol`];
|
||||
}
|
||||
url = urlWithoutProtocol;
|
||||
url = url.substring(protocol.length + 3, url.length);
|
||||
}
|
||||
|
||||
if (url.includes("/")) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user