function toRequestOptions()

in lib/shared.js [17:41]


function toRequestOptions(url, token, headers) {
    headers = headers || {
        'user-agent': 'nodejs'
    };
    if (token) {
        headers['Authorization'] = 'token ' + token;
    }
    var parsedUrl = new URL(url);
    var options = {
        url: url,
        headers: headers
    };
    // We need to test the absence of true here because there is an npm bug that will not set boolean
    // env variables if they are set to false.
    if (process.env.npm_config_strict_ssl !== 'true') {
        options.strictSSL = false;
    }
    if (process.env.npm_config_proxy && parsedUrl.protocol === 'http:') {
        options.proxy = process.env.npm_config_proxy;
    }
    else if (process.env.npm_config_https_proxy && parsedUrl.protocol === 'https:') {
        options.proxy = process.env.npm_config_https_proxy;
    }
    return options;
}