Files
renovate/lib/modules/manager/bundler/host-rules.ts
Sergei Zharinov 930cf6633c refactor: Rewrite imports with .ts extensions (#40700)
fix: Additional vi.mock path corrections and prettier formatting
2026-01-26 22:48:17 +00:00

29 lines
730 B
TypeScript

import type { HostRule } from '../../../types/index.ts';
import { findAll } from '../../../util/host-rules.ts';
function isAuthenticatable(rule: HostRule): boolean {
return (
!!rule.resolvedHost &&
((!!rule.username && !!rule.password) || !!rule.token)
);
}
export function findAllAuthenticatable({
hostType,
}: {
hostType: string;
}): HostRule[] {
return findAll({ hostType }).filter(isAuthenticatable);
}
export function getAuthenticationHeaderValue(hostRule: HostRule): string {
if (hostRule.username) {
const username = encodeURIComponent(hostRule.username);
// TODO: types (#22198)
return `${username}:${hostRule.password!}`;
}
// TODO: types (#22198)
return `${hostRule.token!}`;
}