diff options
Diffstat (limited to 'app/assets/javascripts/registry/explorer/utils.js')
-rw-r--r-- | app/assets/javascripts/registry/explorer/utils.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/app/assets/javascripts/registry/explorer/utils.js b/app/assets/javascripts/registry/explorer/utils.js index 44262a6cbb6..2c89d508c31 100644 --- a/app/assets/javascripts/registry/explorer/utils.js +++ b/app/assets/javascripts/registry/explorer/utils.js @@ -1 +1,16 @@ -export const decodeAndParse = param => JSON.parse(window.atob(param)); +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}`; +}; |