in src/client.ts [340:376]
function getAuth (node?: string | string[] | NodeOptions | NodeOptions[]): { username: string, password: string } | null {
if (Array.isArray(node)) {
for (const url of node) {
const auth = getUsernameAndPassword(url)
if (auth != null && auth.username !== '' && auth.password !== '') {
return auth
}
}
return null
} else {
const auth = getUsernameAndPassword(node)
if (auth != null && auth.username !== '' && auth.password !== '') {
return auth
}
return null
}
function getUsernameAndPassword (node?: string | NodeOptions): { username: string, password: string } | null {
/* istanbul ignore else */
if (typeof node === 'string') {
const { username, password } = new URL(node)
return {
username: decodeURIComponent(username),
password: decodeURIComponent(password)
}
} else if (node != null && node.url instanceof URL) {
return {
username: decodeURIComponent(node.url.username),
password: decodeURIComponent(node.url.password)
}
} else {
return null
}
}
}