diff --git a/lib/modules/datasource/maven/index.ts b/lib/modules/datasource/maven/index.ts index 3b2c752d8714ce659bf35470943140a67f36bd6d..259ce3e2ce573f4de3079c99d4b4737b487d950e 100644 --- a/lib/modules/datasource/maven/index.ts +++ b/lib/modules/datasource/maven/index.ts @@ -114,6 +114,10 @@ export class MavenDatasource extends Datasource { dependency: MavenDependency, repoUrl: string, ): Promise<ReleaseMap> { + if (!repoUrl.startsWith(MAVEN_REPO)) { + return inputReleaseMap; + } + const cacheNs = 'datasource-maven:index-html-releases'; const cacheKey = `${repoUrl}${dependency.dependencyUrl}`; let workingReleaseMap = await packageCache.get<ReleaseMap>( @@ -124,27 +128,21 @@ export class MavenDatasource extends Datasource { workingReleaseMap = {}; let retryEarlier = false; try { - if (repoUrl.startsWith(MAVEN_REPO)) { - const indexUrl = getMavenUrl(dependency, repoUrl, 'index.html'); - const res = await downloadHttpProtocol(this.http, indexUrl); - const { body = '' } = res; - for (const line of body.split(newlineRegex)) { - const match = line.trim().match(mavenCentralHtmlVersionRegex); - if (match) { - const { version, releaseTimestamp: timestamp } = - match?.groups ?? /* istanbul ignore next: hard to test */ {}; - if (version && timestamp) { - const date = DateTime.fromFormat( - timestamp, - 'yyyy-MM-dd HH:mm', - { - zone: 'UTC', - }, - ); - if (date.isValid) { - const releaseTimestamp = date.toISO(); - workingReleaseMap[version] = { version, releaseTimestamp }; - } + const indexUrl = getMavenUrl(dependency, repoUrl, 'index.html'); + const res = await downloadHttpProtocol(this.http, indexUrl); + const { body = '' } = res; + for (const line of body.split(newlineRegex)) { + const match = line.trim().match(mavenCentralHtmlVersionRegex); + if (match) { + const { version, releaseTimestamp: timestamp } = + match?.groups ?? /* istanbul ignore next: hard to test */ {}; + if (version && timestamp) { + const date = DateTime.fromFormat(timestamp, 'yyyy-MM-dd HH:mm', { + zone: 'UTC', + }); + if (date.isValid) { + const releaseTimestamp = date.toISO(); + workingReleaseMap[version] = { version, releaseTimestamp }; } } }