mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-26 15:31:53 +00:00
chore: abort if match strings are empty
This commit is contained in:
@@ -323,6 +323,19 @@ describe('modules/manager/regex/index', () => {
|
||||
expect(res).toBeNull();
|
||||
});
|
||||
|
||||
it('return with recursive strategy if matchStrings is empty', async () => {
|
||||
const config: CustomExtractConfig = {
|
||||
matchStrings: [],
|
||||
matchStringsStrategy: 'recursive',
|
||||
};
|
||||
const res = await extractPackageFile(
|
||||
exampleJsonContent,
|
||||
'example.json',
|
||||
config
|
||||
);
|
||||
expect(res).toBeNull();
|
||||
});
|
||||
|
||||
it('extracts with recursive strategy and single match', async () => {
|
||||
const config: CustomExtractConfig = {
|
||||
matchStrings: [
|
||||
|
||||
@@ -61,6 +61,11 @@ export function handleRecursive(
|
||||
const regexes = config.matchStrings.map((matchString) =>
|
||||
regEx(matchString, 'g')
|
||||
);
|
||||
|
||||
if (!regexes.length) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// abort if we have no matchString anymore
|
||||
if (!regexes[index]) {
|
||||
const result = createDependency(
|
||||
@@ -82,5 +87,6 @@ export function handleRecursive(
|
||||
mergeGroups(combinedGroups, match.groups ?? {})
|
||||
);
|
||||
})
|
||||
.filter(is.truthy)
|
||||
.filter(isValidDependency);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user