mirror of
https://github.com/azure/login.git
synced 2026-03-15 09:20:56 -04:00
* Bump lodash from 4.17.15 to 4.17.19 (#52) Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Amruta Kawade <65217380+AmrutaKawade@users.noreply.github.com> * Bump @actions/core from 1.1.3 to 1.2.6 (#60) Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.1.3 to 1.2.6. - [Release notes](https://github.com/actions/toolkit/releases) - [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md) - [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Amruta Kawade <65217380+AmrutaKawade@users.noreply.github.com> * updating node_nodules * updated package-lock Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
80 lines
2.2 KiB
JavaScript
80 lines
2.2 KiB
JavaScript
'use strict'
|
|
|
|
function formatHostname (hostname) {
|
|
// canonicalize the hostname, so that 'oogle.com' won't match 'google.com'
|
|
return hostname.replace(/^\.*/, '.').toLowerCase()
|
|
}
|
|
|
|
function parseNoProxyZone (zone) {
|
|
zone = zone.trim().toLowerCase()
|
|
|
|
var zoneParts = zone.split(':', 2)
|
|
var zoneHost = formatHostname(zoneParts[0])
|
|
var zonePort = zoneParts[1]
|
|
var hasPort = zone.indexOf(':') > -1
|
|
|
|
return {hostname: zoneHost, port: zonePort, hasPort: hasPort}
|
|
}
|
|
|
|
function uriInNoProxy (uri, noProxy) {
|
|
var port = uri.port || (uri.protocol === 'https:' ? '443' : '80')
|
|
var hostname = formatHostname(uri.hostname)
|
|
var noProxyList = noProxy.split(',')
|
|
|
|
// iterate through the noProxyList until it finds a match.
|
|
return noProxyList.map(parseNoProxyZone).some(function (noProxyZone) {
|
|
var isMatchedAt = hostname.indexOf(noProxyZone.hostname)
|
|
var hostnameMatched = (
|
|
isMatchedAt > -1 &&
|
|
(isMatchedAt === hostname.length - noProxyZone.hostname.length)
|
|
)
|
|
|
|
if (noProxyZone.hasPort) {
|
|
return (port === noProxyZone.port) && hostnameMatched
|
|
}
|
|
|
|
return hostnameMatched
|
|
})
|
|
}
|
|
|
|
function getProxyFromURI (uri) {
|
|
// Decide the proper request proxy to use based on the request URI object and the
|
|
// environmental variables (NO_PROXY, HTTP_PROXY, etc.)
|
|
// respect NO_PROXY environment variables (see: https://lynx.invisible-island.net/lynx2.8.7/breakout/lynx_help/keystrokes/environments.html)
|
|
|
|
var noProxy = process.env.NO_PROXY || process.env.no_proxy || ''
|
|
|
|
// if the noProxy is a wildcard then return null
|
|
|
|
if (noProxy === '*') {
|
|
return null
|
|
}
|
|
|
|
// if the noProxy is not empty and the uri is found return null
|
|
|
|
if (noProxy !== '' && uriInNoProxy(uri, noProxy)) {
|
|
return null
|
|
}
|
|
|
|
// Check for HTTP or HTTPS Proxy in environment Else default to null
|
|
|
|
if (uri.protocol === 'http:') {
|
|
return process.env.HTTP_PROXY ||
|
|
process.env.http_proxy || null
|
|
}
|
|
|
|
if (uri.protocol === 'https:') {
|
|
return process.env.HTTPS_PROXY ||
|
|
process.env.https_proxy ||
|
|
process.env.HTTP_PROXY ||
|
|
process.env.http_proxy || null
|
|
}
|
|
|
|
// if none of that works, return null
|
|
// (What uri protocol are you using then?)
|
|
|
|
return null
|
|
}
|
|
|
|
module.exports = getProxyFromURI
|