Welcome to mirror list, hosted at ThFree Co, Russian Federation.

utils.js « explorer « registry « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2c89d508c31f3698f8675eb56133e1e5c19e6500 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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 splitPath = imageDetails.path.split('/').reverse();
  const splitName = imageDetails.name ? imageDetails.name.split('/').reverse() : [];
  const basePath = splitPath
    .reduce((acc, curr, index) => {
      if (splitPath[index] !== splitName[index]) {
        acc.unshift(curr);
      }
      return acc;
    }, [])
    .join('/');
  return `/${basePath}/registry/repository/${imageDetails.id}/tags${ending}`;
};