(uri)
| 38 | } |
| 39 | |
| 40 | function getProxyFromURI (uri) { |
| 41 | // Decide the proper request proxy to use based on the request URI object and the |
| 42 | // environmental variables (NO_PROXY, HTTP_PROXY, etc.) |
| 43 | // respect NO_PROXY environment variables (see: http://lynx.isc.org/current/breakout/lynx_help/keystrokes/environments.html) |
| 44 | |
| 45 | var noProxy = process.env.NO_PROXY || process.env.no_proxy || '' |
| 46 | |
| 47 | // if the noProxy is a wildcard then return null |
| 48 | |
| 49 | if (noProxy === '*') { |
| 50 | return null |
| 51 | } |
| 52 | |
| 53 | // if the noProxy is not empty and the uri is found return null |
| 54 | |
| 55 | if (noProxy !== '' && uriInNoProxy(uri, noProxy)) { |
| 56 | return null |
| 57 | } |
| 58 | |
| 59 | // Check for HTTP or HTTPS Proxy in environment Else default to null |
| 60 | |
| 61 | if (uri.protocol === 'http:') { |
| 62 | return process.env.HTTP_PROXY || |
| 63 | process.env.http_proxy || null |
| 64 | } |
| 65 | |
| 66 | if (uri.protocol === 'https:') { |
| 67 | return process.env.HTTPS_PROXY || |
| 68 | process.env.https_proxy || |
| 69 | process.env.HTTP_PROXY || |
| 70 | process.env.http_proxy || null |
| 71 | } |
| 72 | |
| 73 | // if none of that works, return null |
| 74 | // (What uri protocol are you using then?) |
| 75 | |
| 76 | return null |
| 77 | } |
| 78 | |
| 79 | module.exports = getProxyFromURI |
no test coverage detected
searching dependent graphs…