diff --git a/lib/manager/regex/index.spec.ts b/lib/manager/regex/index.spec.ts index cdd1f6c0605997e719dab103cdd4d2a6e5510db1..035c2854cc1886b53719e116e7beedc2a43bb9a0 100644 --- a/lib/manager/regex/index.spec.ts +++ b/lib/manager/regex/index.spec.ts @@ -240,6 +240,20 @@ describe('manager/regex/index', () => { expect(res.deps).toHaveLength(1); }); + it('extracts with combination strategy and empty file', async () => { + const config: CustomExtractConfig = { + matchStringsStrategy: 'combination', + matchStrings: [ + 'CHART_REPOSITORY_URL: "(?<registryUrl>.*)\\/(?<depName>[a-z]+)\\/"', + 'CHART_VERSION: (?<currentValue>.*?)\n', + ], + datasourceTemplate: 'helm', + depNameTemplate: 'helm_repo/{{{ depName }}}', + }; + const res = await extractPackageFile('', '.gitlab-ci.yml', config); + expect(res).toBeNull(); + }); + it('extracts with recursive strategy and single match', async () => { const config: CustomExtractConfig = { matchStrings: [ diff --git a/lib/manager/regex/index.ts b/lib/manager/regex/index.ts index 44e44125beaeb0db63cfa4c233f812b6515b771d..9c38450312e9a679fd44dd9996467f7ff6349e3f 100644 --- a/lib/manager/regex/index.ts +++ b/lib/manager/regex/index.ts @@ -147,12 +147,17 @@ function handleCombination( .map((matchString) => regEx(matchString, 'g')) .flatMap((regex) => regexMatchAll(regex, content)); // match all regex to content, get all matches, reduce to single array + if (!matches.length) { + return []; + } + const combinedGroup = matches .map((match) => match.groups) .reduce((mergedGroup, currentGroup) => mergeGroups(mergedGroup, currentGroup) ); + // TODO: this seems to be buggy behavior, needs to be checked #11387 const dep = matches .map((match) => createDependency(match, combinedGroup, config)) .reduce(