Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 704b755c4c | |||
|
bb3f7327cd
|
|||
| 0e8ba09d62 | |||
|
9978b6f900
|
|||
| bd468af1d2 | |||
| ec1003a094 |
+2
-2
@@ -7,7 +7,7 @@ include:
|
|||||||
- project: unboundsoftware/ci-templates
|
- project: unboundsoftware/ci-templates
|
||||||
file: Pre-Commit-Go.gitlab-ci.yml
|
file: Pre-Commit-Go.gitlab-ci.yml
|
||||||
|
|
||||||
image: amd64/golang:1.24.4@sha256:40891f7b63de861049787c5262bff91906d30cbe221753840e276b3e785a66ab
|
image: amd64/golang:1.24.4@sha256:3494bbe140127d12656113203ec91b8e3ff34e8a2b06a0a22bb0d8a41cc69e53
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- deps
|
- deps
|
||||||
@@ -32,7 +32,7 @@ test:
|
|||||||
|
|
||||||
vulnerabilities:
|
vulnerabilities:
|
||||||
stage: test
|
stage: test
|
||||||
image: amd64/golang:1.24.4@sha256:40891f7b63de861049787c5262bff91906d30cbe221753840e276b3e785a66ab
|
image: amd64/golang:1.24.4@sha256:3494bbe140127d12656113203ec91b8e3ff34e8a2b06a0a22bb0d8a41cc69e53
|
||||||
script:
|
script:
|
||||||
- go install golang.org/x/vuln/cmd/govulncheck@latest
|
- go install golang.org/x/vuln/cmd/govulncheck@latest
|
||||||
- govulncheck ./...
|
- govulncheck ./...
|
||||||
|
|||||||
@@ -41,6 +41,6 @@ repos:
|
|||||||
hooks:
|
hooks:
|
||||||
- id: golangci-lint-full
|
- id: golangci-lint-full
|
||||||
- repo: https://github.com/gitleaks/gitleaks
|
- repo: https://github.com/gitleaks/gitleaks
|
||||||
rev: v8.27.0
|
rev: v8.27.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: gitleaks
|
- id: gitleaks
|
||||||
|
|||||||
@@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [0.0.2] - 2025-06-15
|
||||||
|
|
||||||
|
### 🐛 Bug Fixes
|
||||||
|
|
||||||
|
- Update Codecov badge URL in README
|
||||||
|
- *(pagination)* Handle out-of-bounds slicing in pagination
|
||||||
|
|
||||||
## [0.0.1] - 2025-06-07
|
## [0.0.1] - 2025-06-07
|
||||||
|
|
||||||
### 🚀 Features
|
### 🚀 Features
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
Pagination helper
|
Pagination helper
|
||||||
|
|
||||||
[](https://gitlab.com/unboundsoftware/pagination/commits/main)
|
[](https://gitlab.com/unboundsoftware/pagination/commits/main)
|
||||||
[](https://codecov.io/gl/unboundsoftware:pagination)
|
[](https://codecov.io/gl/unboundsoftware/pagination)
|
||||||
|
|||||||
+1
-1
@@ -87,7 +87,7 @@ func GetPage[T any](items []T, first *int, after *string, last *int, before *str
|
|||||||
sIx = f
|
sIx = f
|
||||||
eIx = idx
|
eIx = idx
|
||||||
}
|
}
|
||||||
page := items[sIx:eIx]
|
page := items[sIx:min(eIx, len(items))]
|
||||||
return page, PageInfo{
|
return page, PageInfo{
|
||||||
StartCursor: ptr(EncodeCursor(fn(page[0]))),
|
StartCursor: ptr(EncodeCursor(fn(page[0]))),
|
||||||
HasNextPage: eIx < len(items),
|
HasNextPage: eIx < len(items),
|
||||||
|
|||||||
@@ -39,6 +39,16 @@ func TestGetPage(t *testing.T) {
|
|||||||
EndCursor: ptr("Mg=="),
|
EndCursor: ptr("Mg=="),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "first 10",
|
||||||
|
args: args[string]{items: []string{"1", "2", "3"}, first: ptr(10), max: 10, fn: func(s string) string { return s }},
|
||||||
|
wantItems: []string{"1", "2", "3"},
|
||||||
|
wantPageInfo: PageInfo{
|
||||||
|
StartCursor: ptr("MQ=="),
|
||||||
|
HasNextPage: false,
|
||||||
|
EndCursor: ptr("Mw=="),
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "after 2",
|
name: "after 2",
|
||||||
args: args[string]{items: []string{"1", "2", "3", "4"}, first: ptr(2), after: ptr("Mg=="), max: 10, fn: func(s string) string { return s }},
|
args: args[string]{items: []string{"1", "2", "3", "4"}, first: ptr(2), after: ptr("Mg=="), max: 10, fn: func(s string) string { return s }},
|
||||||
|
|||||||
Reference in New Issue
Block a user