Skip to content

Commit

Permalink
fix: Only add / for lookup, not for returned registry (#8888)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
candrews committed Feb 28, 2021
1 parent 58dc33b commit e136cd4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/datasource/docker/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
`;
Expand Down
7 changes: 4 additions & 3 deletions lib/datasource/docker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, ''),
};
}
}
Expand Down

0 comments on commit e136cd4

Please sign in to comment.