renovate/lib/util/package-rules/sourceurl-prefixes.ts
renovate[bot] e5cbbaaf09
build(deps): update dependency prettier to v3 (#23627)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Sergei Zharinov <zharinov@users.noreply.github.com>
2023-11-07 17:12:01 +00:00

22 lines
652 B
TypeScript

import is from '@sindresorhus/is';
import type { PackageRule, PackageRuleInputConfig } from '../../config/types';
import { Matcher } from './base';
export class SourceUrlPrefixesMatcher extends Matcher {
override matches(
{ sourceUrl }: PackageRuleInputConfig,
{ matchSourceUrlPrefixes }: PackageRule,
): boolean | null {
if (is.undefined(matchSourceUrlPrefixes)) {
return null;
}
if (is.undefined(sourceUrl)) {
return false;
}
const upperCaseSourceUrl = sourceUrl?.toUpperCase();
return matchSourceUrlPrefixes.some(
(prefix) => upperCaseSourceUrl?.startsWith(prefix.toUpperCase()),
);
}
}