refactor: version cursor - update payload
This commit is contained in:
parent
186c8d6765
commit
74c5d842ce
|
@ -241,6 +241,7 @@ var ErrNil error = simpleError{
|
|||
code: "nil",
|
||||
}
|
||||
|
||||
// ErrInvalidCursor is an error that is returned when a cursor can't be decoded (e.g. is malformed).
|
||||
var ErrInvalidCursor error = simpleError{
|
||||
msg: "invalid cursor",
|
||||
typ: ErrorTypeIncorrectInput,
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/base64"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -140,13 +141,19 @@ func decodeVersionCursor(encoded string) (VersionCursor, error) {
|
|||
return VersionCursor{}, err
|
||||
}
|
||||
|
||||
decoded, err := base64.StdEncoding.DecodeString(encoded)
|
||||
decodedBytes, err := base64.StdEncoding.DecodeString(encoded)
|
||||
if err != nil {
|
||||
return VersionCursor{}, ErrInvalidCursor
|
||||
}
|
||||
decoded := string(decodedBytes)
|
||||
|
||||
code, ok := strings.CutPrefix(decoded, "code=")
|
||||
if !ok {
|
||||
return VersionCursor{}, ErrInvalidCursor
|
||||
}
|
||||
|
||||
vc, err := NewVersionCursor(NullString{
|
||||
Value: string(decoded),
|
||||
Value: code,
|
||||
Valid: true,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -169,7 +176,7 @@ func (vc VersionCursor) Encode() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
return base64.StdEncoding.EncodeToString([]byte(vc.code.Value))
|
||||
return base64.StdEncoding.EncodeToString([]byte("code=" + vc.code.Value))
|
||||
}
|
||||
|
||||
type ListVersionsParams struct {
|
||||
|
|
Loading…
Reference in New Issue