17 lines
507 B
TypeScript
17 lines
507 B
TypeScript
export function createProxyUrl(proxy: {
|
|
protocol: string;
|
|
host: string;
|
|
port: number;
|
|
username?: string;
|
|
password?: string;
|
|
}): string {
|
|
const { protocol, host, port, username, password } = proxy;
|
|
if (username && password) {
|
|
return `${protocol}://${encodeURIComponent(username)}:${encodeURIComponent(password)}@${host}:${port}`;
|
|
}
|
|
return `${protocol}://${host}:${port}`;
|
|
}
|
|
|
|
export function sleep(ms: number): Promise<void> {
|
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
}
|