From e136cd4424dc4bacd89ec899c0a71e5e85f5a009 Mon Sep 17 00:00:00 2001 From: Craig Andrews <candrews@integralblue.com> Date: Sun, 28 Feb 2021 01:53:42 -0500 Subject: [PATCH] fix: Only add / for lookup, not for returned registry (#8888) When checking to see if lookupName starts with the registry, append a / (if not already present) to the registry. Do not append the / when returning the registry. --- lib/datasource/docker/__snapshots__/index.spec.ts.snap | 2 +- lib/datasource/docker/index.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/datasource/docker/__snapshots__/index.spec.ts.snap b/lib/datasource/docker/__snapshots__/index.spec.ts.snap index e828b71238..40b5985e56 100644 --- a/lib/datasource/docker/__snapshots__/index.spec.ts.snap +++ b/lib/datasource/docker/__snapshots__/index.spec.ts.snap @@ -392,7 +392,7 @@ Object { exports[`datasource/docker/index getRegistryRepository supports registryUrls 1`] = ` Object { - "registry": "my.local.registry/prefix/", + "registry": "my.local.registry/prefix", "repository": "image", } `; diff --git a/lib/datasource/docker/index.ts b/lib/datasource/docker/index.ts index f724fbc4ea..1d1f582083 100644 --- a/lib/datasource/docker/index.ts +++ b/lib/datasource/docker/index.ts @@ -66,11 +66,12 @@ export function getRegistryRepository( registryUrl: string ): RegistryRepository { if (registryUrl !== defaultRegistryUrls[0]) { - const registry = registryUrl.replace('https://', '').replace(/\/?$/, '/'); - if (lookupName.startsWith(registry)) { + const registry = registryUrl.replace('https://', ''); + const registryEndingWithSlash = registry.replace(/\/?$/, '/'); + if (lookupName.startsWith(registryEndingWithSlash)) { return { registry, - repository: lookupName.replace(registry, ''), + repository: lookupName.replace(registryEndingWithSlash, ''), }; } } -- GitLab