mirror of
https://github.com/project-zot/zot.git
synced 2025-01-06 22:40:28 -05:00
feat(pagination): make sure the URL to in the link header is inside angle brackets (#2116)
Signed-off-by: Andrei Aaron <aaaron@luxoft.com>
This commit is contained in:
parent
e3bd9a8fa8
commit
f321fa91fe
3 changed files with 12 additions and 4 deletions
|
@ -7303,7 +7303,7 @@ func TestListingTags(t *testing.T) {
|
||||||
} else if testCase.expectedTags[len(testCase.expectedTags)-1] == alltags[len(alltags)-1] {
|
} else if testCase.expectedTags[len(testCase.expectedTags)-1] == alltags[len(alltags)-1] {
|
||||||
So(actualLinkValue, ShouldEqual, "")
|
So(actualLinkValue, ShouldEqual, "")
|
||||||
} else {
|
} else {
|
||||||
expectedLinkValue := fmt.Sprintf("/v2/%s/tags/list?n=%s&last=%s; rel=\"next\"",
|
expectedLinkValue := fmt.Sprintf("</v2/%s/tags/list?n=%s&last=%s>; rel=\"next\"",
|
||||||
repoName, testCase.pageSize, tags.Tags[len(tags.Tags)-1],
|
repoName, testCase.pageSize, tags.Tags[len(tags.Tags)-1],
|
||||||
)
|
)
|
||||||
So(actualLinkValue, ShouldEqual, expectedLinkValue)
|
So(actualLinkValue, ShouldEqual, expectedLinkValue)
|
||||||
|
|
|
@ -375,7 +375,7 @@ func (rh *RouteHandler) ListTags(response http.ResponseWriter, request *http.Req
|
||||||
stopIndex = startIndex + numTags - 1
|
stopIndex = startIndex + numTags - 1
|
||||||
response.Header().Set(
|
response.Header().Set(
|
||||||
"Link",
|
"Link",
|
||||||
fmt.Sprintf("/v2/%s/tags/list?n=%d&last=%s; rel=\"next\"",
|
fmt.Sprintf("</v2/%s/tags/list?n=%d&last=%s>; rel=\"next\"",
|
||||||
name,
|
name,
|
||||||
numTags,
|
numTags,
|
||||||
tags[stopIndex],
|
tags[stopIndex],
|
||||||
|
|
|
@ -602,8 +602,16 @@ func CheckWorkflows(t *testing.T, config *compliance.Config) {
|
||||||
next := resp.Header().Get("Link")
|
next := resp.Header().Get("Link")
|
||||||
So(next, ShouldNotBeEmpty)
|
So(next, ShouldNotBeEmpty)
|
||||||
|
|
||||||
u := baseURL + strings.Split(next, ";")[0]
|
nextURL := strings.Split(next, ";")[0]
|
||||||
resp, err = resty.R().Get(u)
|
if strings.HasPrefix(nextURL, "<") || strings.HasPrefix(nextURL, "\"") {
|
||||||
|
nextURL = nextURL[1:]
|
||||||
|
}
|
||||||
|
if strings.HasSuffix(nextURL, ">") || strings.HasSuffix(nextURL, "\"") {
|
||||||
|
nextURL = nextURL[:len(nextURL)-1]
|
||||||
|
}
|
||||||
|
nextURL = baseURL + nextURL
|
||||||
|
|
||||||
|
resp, err = resty.R().Get(nextURL)
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
|
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
|
||||||
next = resp.Header().Get("Link")
|
next = resp.Header().Get("Link")
|
||||||
|
|
Loading…
Reference in a new issue