@@ -491,16 +491,16 @@ exports.toURLEncode = function(value) {
491491
492492exports . resolve = function ( url , callback , param ) {
493493
494- var uri ;
494+ let uri ;
495495
496496 try {
497- uri = F . Url . parse ( url ) ;
497+ uri = new URL ( url ) ;
498498 } catch ( e ) {
499499 callback ( e ) ;
500500 return ;
501501 }
502502
503- var cache = F . temporary . dnscache [ uri . host ] ;
503+ const cache = F . temporary . dnscache [ uri . host ] ;
504504
505505 if ( ! callback )
506506 return cache ;
@@ -538,18 +538,18 @@ function keywordscleaner(c) {
538538
539539function parseProxy ( p ) {
540540
541- var key = 'proxy_' + p ;
541+ const key = 'proxy_' + p ;
542542
543543 if ( F . temporary . utils [ key ] )
544544 return F . temporary . utils [ key ] ;
545545
546546 if ( p . indexOf ( '://' ) === - 1 )
547547 p = 'http://' + p ;
548548
549- var obj = F . Url . parse ( p ) ;
549+ const obj = new URL ( p ) ;
550550
551- if ( obj . auth )
552- obj . _auth = 'Basic ' + Buffer . from ( obj . auth ) . toString ( 'base64' ) ;
551+ if ( obj . username || obj . password )
552+ obj . _auth = 'Basic ' + Buffer . from ( obj . username + ':' + obj . password ) . toString ( 'base64' ) ;
553553
554554 obj . port = + obj . port ;
555555
@@ -563,7 +563,7 @@ function parseProxy(p) {
563563
564564function _request ( opt , callback ) {
565565
566- var options = { length : 0 , timeout : opt . timeout == false || opt . timeout == 0 ? 0 : ( opt . timeout || 8000 ) , encoding : opt . encoding || 'utf8' , callback : callback || opt . callback || NOOP , post : true , redirect : 0 } ;
566+ const options = { length : 0 , timeout : opt . timeout == false || opt . timeout == 0 ? 0 : ( opt . timeout || 8000 ) , encoding : opt . encoding || 'utf8' , callback : callback || opt . callback || NOOP , post : true , redirect : 0 } ;
567567 var proxy ;
568568
569569 F . stats . performance . external ++ ;
@@ -691,7 +691,7 @@ function _request(opt, callback) {
691691 }
692692 }
693693
694- var uri = opt . unixsocket ? { socketPath : opt . unixsocket . socket , path : opt . unixsocket . path } : F . Url . parse ( opt . url ) ;
694+ const uri = opt . unixsocket ? { socketPath : opt . unixsocket . socket , path : opt . unixsocket . path } : new URL ( opt . url ) ;
695695
696696 if ( ( opt . unixsocket && ! uri . socketPath ) || ( ! opt . unixsocket && ( ! uri . hostname || ! uri . host ) ) ) {
697697 options . response . canceled = true ;
@@ -794,9 +794,9 @@ PAP.createConnection = function(pending) {
794794
795795PAP . createSocket = function ( options , callback ) {
796796
797- var self = this ;
798- var proxy = self . options . proxy ;
799- var uri = self . options . uri ;
797+ const self = this ;
798+ const proxy = self . options . proxy ;
799+ const uri = self . options . uri ;
800800
801801 PROXYOPTIONS . host = proxy . hostname ;
802802 PROXYOPTIONS . port = proxy . port ;
@@ -805,7 +805,7 @@ PAP.createSocket = function(options, callback) {
805805 if ( proxy . _auth )
806806 PROXYOPTIONS . headers [ 'Proxy-Authorization' ] = proxy . _auth ;
807807
808- var req = self . request ( PROXYOPTIONS ) ;
808+ const req = self . request ( PROXYOPTIONS ) ;
809809 req . setTimeout ( 10000 ) ;
810810 req . on ( 'response' , proxyagent_response ) ;
811811 req . on ( 'connect' , function ( res , socket ) {
@@ -825,7 +825,7 @@ PAP.createSocket = function(options, callback) {
825825 } ) ;
826826
827827 req . on ( 'error' , function ( err ) {
828- var e = new Error ( 'Request Proxy "proxy {0} --> target {1}": {2}' . format ( PROXYOPTIONS . host + ':' + proxy . port , PROXYOPTIONS . path , err . toString ( ) ) ) ;
828+ const e = new Error ( 'Request Proxy "proxy {0} --> target {1}": {2}' . format ( PROXYOPTIONS . host + ':' + proxy . port , PROXYOPTIONS . path , err . toString ( ) ) ) ;
829829 e . code = err . code ;
830830 req . destroy && req . destroy ( ) ;
831831 req = null ;
@@ -1030,8 +1030,8 @@ function request_writefile(req, options, file, next) {
10301030
10311031function request_response ( res ) {
10321032
1033- var options = this . $options ;
1034- var uri = this . $uri ;
1033+ const options = this . $options ;
1034+ const uri = this . $uri ;
10351035
10361036 res . _buffer = null ;
10371037 res . _bufferlength = 0 ;
@@ -1093,18 +1093,18 @@ function request_response(res) {
10931093
10941094 options . redirect ++ ;
10951095
1096- var loc = res . headers . location ;
1097- var proto = loc . substring ( 0 , 6 ) ;
1096+ let loc = res . headers . location ;
1097+ const proto = loc . substring ( 0 , 6 ) ;
10981098
10991099 if ( proto !== 'http:/' && proto !== 'https:' )
11001100 loc = uri . protocol + '//' + uri . hostname + ( uri . port && ! SKI_PPORTS [ uri . port ] ? ( ':' + uri . port ) : '' ) + loc ;
11011101
1102- var tmp = F . Url . parse ( loc ) ;
1102+ var tmp = new URL ( loc ) ;
11031103 tmp . headers = uri . headers ;
11041104
11051105 // Transfers cookies
11061106 if ( ! options . nocookies ) {
1107- var cookies = res . headers [ 'set-cookie' ] ;
1107+ const cookies = res . headers [ 'set-cookie' ] ;
11081108 if ( cookies ) {
11091109
11101110 if ( options . $totalinit . cook && ! options . $totalinit . cookies )
@@ -1113,9 +1113,9 @@ function request_response(res) {
11131113 if ( ! options . cookies )
11141114 options . cookies = { } ;
11151115
1116- for ( var i = 0 ; i < cookies . length ; i ++ ) {
1117- var cookie = cookies [ i ] ;
1118- var index = cookie . indexOf ( ';' ) ;
1116+ for ( let i = 0 ; i < cookies . length ; i ++ ) {
1117+ let cookie = cookies [ i ] ;
1118+ let index = cookie . indexOf ( ';' ) ;
11191119 if ( index !== - 1 ) {
11201120 cookie = cookie . substring ( 0 , index ) ;
11211121 index = cookie . indexOf ( '=' ) ;
0 commit comments