Skip to content

Commit

Permalink
Change to RawURLEncoding
Browse files Browse the repository at this point in the history
  • Loading branch information
kad-korpem committed Feb 21, 2024
1 parent 222a032 commit dd47e99
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions ogc/features/domain/cursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func encodeCursor(fid int64, filtersChecksum []byte) EncodedCursor {
fidAsBytes := big.NewInt(fid).Bytes()

// format of the cursor: <encoded fid><separator><encoded checksum>
return EncodedCursor(base64.RawStdEncoding.EncodeToString(fidAsBytes) + string(separator) + base64.RawStdEncoding.EncodeToString(filtersChecksum))
return EncodedCursor(base64.RawURLEncoding.EncodeToString(fidAsBytes) + string(separator) + base64.RawURLEncoding.EncodeToString(filtersChecksum))
}

// Decode turns encoded cursor into DecodedCursor and verifies the
Expand All @@ -69,8 +69,8 @@ func (c EncodedCursor) Decode(filtersChecksum []byte) DecodedCursor {
log.Printf("cursor '%s' doesn't contain expected separator %c", value, separator)
return DecodedCursor{filtersChecksum, 0}
}
decodedFid, fidErr := base64.RawStdEncoding.DecodeString(encoded[0])
decodedChecksum, checksumErr := base64.RawStdEncoding.DecodeString(encoded[1])
decodedFid, fidErr := base64.RawURLEncoding.DecodeString(encoded[0])
decodedChecksum, checksumErr := base64.RawURLEncoding.DecodeString(encoded[1])
if fidErr != nil || checksumErr != nil {
log.Printf("decoding cursor value '%s' failed, defaulting to first page", value)
return DecodedCursor{filtersChecksum, 0}
Expand Down
2 changes: 1 addition & 1 deletion ogc/features/domain/cursor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func TestEncodedCursor_Pagination(t *testing.T) {
}{
{
name: "should not reset to first page",
c: "Z3Z8%7C%2BQ8mwg",
c: "Z3Z8%7C-Q8mwg",
args: args{
filtersChecksum: []byte{249, 15, 38, 194},
},
Expand Down

0 comments on commit dd47e99

Please sign in to comment.