0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-01-12 22:29:06 +00:00
renovatebot_renovate/lib/modules/manager/bundler/host-rules.ts
John Andrews 6560bedab8
fix(manager/bundler): Escape special characters in bundler usernames (#32229)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2024-10-31 13:25:21 +00:00

28 lines
718 B
TypeScript

import type { HostRule } from '../../../types';
import { findAll } from '../../../util/host-rules';
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!}`;
}