Skip to content
Snippets Groups Projects
Unverified Commit 5273cbc1 authored by Jennifer Wilcox's avatar Jennifer Wilcox Committed by GitHub
Browse files

fix(docker): handle redundant port in image (#11852)

parent e37f339e
No related branches found
No related tags found
No related merge requests found
......@@ -81,7 +81,7 @@ describe('util/url', () => {
it('ensures path prefix', () => {
expect(ensurePathPrefix('https://index.docker.io', '/v2')).toBe(
'https://index.docker.io/v2'
'https://index.docker.io/v2/'
);
expect(ensurePathPrefix('https://index.docker.io/v2', '/v2')).toBe(
'https://index.docker.io/v2'
......@@ -89,6 +89,12 @@ describe('util/url', () => {
expect(
ensurePathPrefix('https://index.docker.io/v2/something', '/v2')
).toBe('https://index.docker.io/v2/something');
expect(ensurePathPrefix('https://index.docker.io:443', '/v2')).toBe(
'https://index.docker.io/v2/'
);
expect(
ensurePathPrefix('https://index.docker.io/something?with=query', '/v2')
).toBe('https://index.docker.io/v2/something?with=query');
});
it('joinUrlParts', () => {
......
......@@ -6,7 +6,7 @@ export function joinUrlParts(...parts: string[]): string {
export function ensurePathPrefix(url: string, prefix: string): string {
const parsed = new URL(url);
const fullPath = url.replace(parsed.origin, '');
const fullPath = parsed.pathname + parsed.search;
if (fullPath.startsWith(prefix)) {
return url;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment