// convert a database name to a URL, if it isn't already var convertToURL = function (x) { var parsed = new url.URL(x) // if it is a URL already if (parsed.protocol) { return parsed.href } else { return process.env.COUCH_URL + '/' + encodeURIComponent(x) } }
/** * Updates the given NPM config with the specified options. */ function updateConfig(config: string, { registry, debug }: NormalizedOptions): string { let authDomain = registry.origin.slice(registry.protocol.length); let lines = config.split(/\r?\n/); // Remove any existing lines that set the registry or token lines = lines.filter((line) => !(line.startsWith("registry=") || line.includes("_authToken=")) ); // Append the new registry and token to the end of the file lines.push(`${authDomain}/:_authToken=\${INPUT_TOKEN}`); lines.push(`registry=${registry.href}`); config = lines.join(EOL).trim() + EOL; debug(`NEW NPM CONFIG: \n${config}`); return config; }
// Is the value of a `funding` property of a `package.json` // a valid type+url for `npm fund` to display? function validFundingField (funding) { if (!funding) return false if (Array.isArray(funding)) { return funding.every(f => !Array.isArray(f) && validFundingField(f)) } try { var parsed = new URL(funding.url || funding) } catch (error) { return false } if ( parsed.protocol !== 'https:' && parsed.protocol !== 'http:' ) return false return Boolean(parsed.host) }
if (u.protocol === 'https:' && (port === 443 || port === 8123)) { u.port = ''; } else if (! u.port && port) {
let proxy; if (apiUrl.protocol == "http:") { proxy = process.env["HTTP_PROXY"] || process.env["http_proxy"]; } else {
if (tmpUri.protocol === 'ipc:') { await mkdirp(path.dirname(tmpUri.pathname))
const origUrl = new URL(url); redirUrl.hostname = origUrl.hostname; redirUrl.protocol = origUrl.protocol;
const origUrl = new URL(url); redirUrl.hostname = origUrl.hostname; redirUrl.protocol = origUrl.protocol;