@@ -48,38 +48,38 @@ export function makeProxyAgent(proxy: Proxy | string): HttpsProxyAgent<string> |
4848}
4949
5050export function makeProxyAgentUndici ( proxy : Proxy | string ) : ProxyAgent | SocksProxyAgent {
51- let proxyUrl : string
52- let protocol : string
51+ let proxyUrl : string ;
52+ let protocol : string ;
5353
5454 if ( typeof proxy === 'string' ) {
55- const url = new URL ( proxy )
56- protocol = url . protocol . replace ( ':' , '' )
57- proxyUrl = proxy
55+ const url = new URL ( proxy ) ;
56+ protocol = url . protocol . replace ( ':' , '' ) ;
57+ proxyUrl = proxy ;
5858 } else {
59- const { host, password, port, protocol : proto , username } = proxy
60- protocol = ( proto || 'http' ) . replace ( ':' , '' )
59+ const { host, password, port, protocol : proto , username } = proxy ;
60+ protocol = ( proto || 'http' ) . replace ( ':' , '' ) ;
6161
6262 if ( protocol === 'socks' ) {
63- protocol = 'socks5'
63+ protocol = 'socks5' ;
6464 }
6565
66- const auth = username && password ? `${ username } :${ password } @` : ''
67- proxyUrl = `${ protocol } ://${ auth } ${ host } :${ port } `
66+ const auth = username && password ? `${ username } :${ password } @` : '' ;
67+ proxyUrl = `${ protocol } ://${ auth } ${ host } :${ port } ` ;
6868 }
69-
70- const PROXY_HTTP_PROTOCOL = 'http'
71- const PROXY_HTTPS_PROTOCOL = 'https'
72- const PROXY_SOCKS4_PROTOCOL = 'socks4'
73- const PROXY_SOCKS5_PROTOCOL = 'socks5'
69+ ;
70+ const PROXY_HTTP_PROTOCOL = 'http' ;
71+ const PROXY_HTTPS_PROTOCOL = 'https' ;
72+ const PROXY_SOCKS4_PROTOCOL = 'socks4' ;
73+ const PROXY_SOCKS5_PROTOCOL = 'socks5' ;
7474
7575 switch ( protocol ) {
7676 case PROXY_HTTP_PROTOCOL :
7777 case PROXY_HTTPS_PROTOCOL :
78- return new ProxyAgent ( proxyUrl )
78+ return new ProxyAgent ( proxyUrl ) ;
7979 case PROXY_SOCKS4_PROTOCOL :
8080 case PROXY_SOCKS5_PROTOCOL :
81- return new SocksProxyAgent ( proxyUrl )
81+ return new SocksProxyAgent ( proxyUrl ) ;
8282 default :
83- throw new Error ( `Unsupported proxy protocol: ${ protocol } ` )
83+ throw new Error ( `Unsupported proxy protocol: ${ protocol } ` ) ;
8484 }
8585}
0 commit comments