Skip to content

Commit

Permalink
fix(docker): exclude path from registry (#10144)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins authored May 26, 2021
1 parent f2958dc commit 9209fad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
12 changes: 6 additions & 6 deletions lib/datasource/docker/common.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ describe(getName(), () => {
);
expect(res).toMatchInlineSnapshot(`
Object {
"dockerRepository": "image",
"registryHost": "https://my.local.registry/prefix",
"dockerRepository": "prefix/image",
"registryHost": "https://my.local.registry",
}
`);
});
Expand All @@ -55,8 +55,8 @@ describe(getName(), () => {
);
expect(res).toMatchInlineSnapshot(`
Object {
"dockerRepository": "image",
"registryHost": "http://my.local.registry/prefix",
"dockerRepository": "prefix/image",
"registryHost": "http://my.local.registry",
}
`);
});
Expand All @@ -67,8 +67,8 @@ describe(getName(), () => {
);
expect(res).toMatchInlineSnapshot(`
Object {
"dockerRepository": "image",
"registryHost": "https://my.local.registry/prefix",
"dockerRepository": "prefix/image",
"registryHost": "https://my.local.registry",
}
`);
});
Expand Down
13 changes: 11 additions & 2 deletions lib/datasource/docker/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import * as packageCache from '../../util/cache/package';
import * as hostRules from '../../util/host-rules';
import { Http, HttpResponse } from '../../util/http';
import type { OutgoingHttpHeaders } from '../../util/http/types';
import { ensureTrailingSlash, trimTrailingSlash } from '../../util/url';
import {
ensureTrailingSlash,
parseUrl,
trimTrailingSlash,
} from '../../util/url';
import { MediaType, RegistryRepository } from './types';

export const id = 'docker';
Expand Down Expand Up @@ -165,9 +169,14 @@ export function getRegistryRepository(
if (!/^https?:\/\//.test(registryHost)) {
registryHost = `https://${registryHost}`;
}
let dockerRepository = lookupName.replace(registryEndingWithSlash, '');
const fullUrl = `${registryHost}/${dockerRepository}`;
const { origin, pathname } = parseUrl(fullUrl);
registryHost = origin;
dockerRepository = pathname.substring(1);
return {
registryHost,
dockerRepository: lookupName.replace(registryEndingWithSlash, ''),
dockerRepository,
};
}
}
Expand Down

0 comments on commit 9209fad

Please sign in to comment.