Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
41fc8225
Commit
41fc8225
authored
Nov 27, 2020
by
Nicolò Maria Mezzopera
Committed by
Brandon Labuschagne
Nov 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix container_registry url for relative urls
- update utility - add more test cases
parent
2abdaa63
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
4 deletions
+29
-4
app/assets/javascripts/registry/explorer/utils.js
app/assets/javascripts/registry/explorer/utils.js
+10
-1
changelogs/unreleased/288752-registry-details-relative-url-fix.yml
...s/unreleased/288752-registry-details-relative-url-fix.yml
+5
-0
spec/frontend/registry/explorer/utils_spec.js
spec/frontend/registry/explorer/utils_spec.js
+14
-3
No files found.
app/assets/javascripts/registry/explorer/utils.js
View file @
41fc8225
import
{
joinPaths
}
from
'
~/lib/utils/url_utility
'
;
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
...
...
@@ -12,5 +14,12 @@ export const pathGenerator = (imageDetails, ending = '?format=json') => {
return
acc
;
},
[])
.
join
(
'
/
'
);
return
`/
${
basePath
}
/registry/repository/
${
imageDetails
.
id
}
/tags
${
ending
}
`
;
return
joinPaths
(
window
.
gon
.
relative_url_root
,
`/
${
basePath
}
`
,
'
/registry/repository/
'
,
`
${
imageDetails
.
id
}
`
,
`tags
${
ending
}
`
,
);
};
changelogs/unreleased/288752-registry-details-relative-url-fix.yml
0 → 100644
View file @
41fc8225
---
title
:
Fix container_registry url for relative urls
merge_request
:
48661
author
:
type
:
fixed
spec/frontend/registry/explorer/utils_spec.js
View file @
41fc8225
...
...
@@ -8,6 +8,10 @@ describe('Utils', () => {
id
:
1
,
};
beforeEach
(()
=>
{
window
.
gon
.
relative_url_root
=
null
;
});
it
(
'
returns the fetch url when no ending is passed
'
,
()
=>
{
expect
(
pathGenerator
(
imageDetails
)).
toBe
(
'
/foo/bar/registry/repository/1/tags?format=json
'
);
});
...
...
@@ -16,7 +20,7 @@ describe('Utils', () => {
expect
(
pathGenerator
(
imageDetails
,
'
/foo
'
)).
toBe
(
'
/foo/bar/registry/repository/1/tags/foo
'
);
});
it
.
each
`
describe
.
each
`
path | name | result
${
'
foo/foo
'
}
|
${
''
}
|
${
'
/foo/foo/registry/repository/1/tags?format=json
'
}
${
'
foo/foo/foo
'
}
|
${
'
foo
'
}
|
${
'
/foo/foo/registry/repository/1/tags?format=json
'
}
...
...
@@ -26,8 +30,15 @@ describe('Utils', () => {
${
'
foo/foo/baz/foo/bar
'
}
|
${
'
foo/bar
'
}
|
${
'
/foo/foo/baz/registry/repository/1/tags?format=json
'
}
${
'
baz/foo/foo
'
}
|
${
'
foo
'
}
|
${
'
/baz/foo/registry/repository/1/tags?format=json
'
}
${
'
baz/foo/bar
'
}
|
${
'
foo
'
}
|
${
'
/baz/foo/bar/registry/repository/1/tags?format=json
'
}
`
(
'
returns the correct path when path is $path and name is $name
'
,
({
name
,
path
,
result
})
=>
{
expect
(
pathGenerator
({
id
:
1
,
name
,
path
})).
toBe
(
result
);
`
(
'
when path is $path and name is $name
'
,
({
name
,
path
,
result
})
=>
{
it
(
'
returns the correct value
'
,
()
=>
{
expect
(
pathGenerator
({
id
:
1
,
name
,
path
})).
toBe
(
result
);
});
it
(
'
produces a correct relative url
'
,
()
=>
{
window
.
gon
.
relative_url_root
=
'
/gitlab
'
;
expect
(
pathGenerator
({
id
:
1
,
name
,
path
})).
toBe
(
`/gitlab
${
result
}
`
);
});
});
it
(
'
returns the url unchanged when imageDetails have no name
'
,
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment