mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-09 05:32:24 +00:00
dda2ebce92
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
23 lines
649 B
TypeScript
23 lines
649 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())
|
|
);
|
|
}
|
|
}
|