1
- // eavily inspired by https://github.com/SAP/connect-openui5/blob/master/lib/proxy.js
1
+ // heavily inspired by https://github.com/SAP/connect-openui5/blob/master/lib/proxy.js
2
2
const url = require ( "url" ) ;
3
3
const httpProxy = require ( "http-proxy" ) ;
4
4
@@ -9,14 +9,18 @@ const env = {
9
9
} ;
10
10
11
11
function getProxyUri ( uri ) {
12
+ console . log ( "1" , env )
12
13
if ( uri . protocol === "https:" && env . httpsProxy || uri . protocol === "http:" && env . httpProxy ) {
13
- if ( env . noProxy ) {
14
+ console . log ( "2" )
15
+ if ( env . noProxy ) { console . log ( "3" )
14
16
const canonicalHost = uri . host . replace ( / ^ \. * / , "." ) ;
15
17
const port = uri . port || ( uri . protocol === "https:" ? "443" : "80" ) ;
16
18
17
19
const patterns = env . noProxy . split ( "," ) ;
18
20
for ( let i = patterns . length - 1 ; i >= 0 ; i -- ) {
21
+ console . log ( "4" )
19
22
let pattern = patterns [ i ] . trim ( ) . toLowerCase ( ) ;
23
+ console . log ( canonicalHost , pattern )
20
24
21
25
// don"t use a proxy at all
22
26
if ( pattern === "*" ) {
@@ -26,11 +30,7 @@ function getProxyUri(uri) {
26
30
// Remove leading * and make sure to have exact one leading dot (.)
27
31
pattern = pattern . replace ( / ^ [ * ] + / , "" ) . replace ( / ^ \. * / , "." ) ;
28
32
29
- // add port if no specified
30
- if ( pattern . indexOf ( ":" ) === - 1 ) {
31
- pattern += ":" + port ;
32
- }
33
-
33
+ console . log ( canonicalHost , pattern )
34
34
// if host ends with pattern, no proxy should be used
35
35
if ( canonicalHost . indexOf ( pattern ) === canonicalHost . length - pattern . length ) {
36
36
return null ;
0 commit comments