Commit e41cddf1 authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera

Merge branch 'ntepluhina-fix-path-generator' into 'master'

Fixed container registry pathGenerator to count on empty name

See merge request gitlab-org/gitlab!47421
parents 555c516a c8eb1dc2
export const pathGenerator = (imageDetails, ending = '?format=json') => {
// this method is a temporary workaround, to be removed with graphql implementation
// https://gitlab.com/gitlab-org/gitlab/-/issues/276432
const basePath = imageDetails.path.replace(`/${imageDetails.name}`, '');
const basePath = imageDetails.name
? imageDetails.path.replace(`/${imageDetails.name}`, '')
: imageDetails.path;
return `/${basePath}/registry/repository/${imageDetails.id}/tags${ending}`;
};
......@@ -15,5 +15,17 @@ describe('Utils', () => {
it('returns the url with an ending when is passed', () => {
expect(pathGenerator(imageDetails, '/foo')).toBe('/foo/bar/registry/repository/1/tags/foo');
});
it('returns the url unchanged when imageDetails have no name', () => {
const imageDetailsWithoutName = {
path: 'foo/bar/baz',
name: '',
id: 1,
};
expect(pathGenerator(imageDetailsWithoutName)).toBe(
'/foo/bar/baz/registry/repository/1/tags?format=json',
);
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment