Skip to content

Commit

Permalink
Change to url safe base64
Browse files Browse the repository at this point in the history
  • Loading branch information
JProgrammer committed May 16, 2024
1 parent 7ad9771 commit 79a6396
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/activerecord_cursor_paginate/cursor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def from_record(record, columns:)
end

def decode(cursor_string:, columns:)
decoded = JSON.parse(Base64.strict_decode64(cursor_string))
decoded = JSON.parse(Base64.urlsafe_decode64(cursor_string))

if (columns.size == 1 && decoded.is_a?(Array)) ||
(decoded.is_a?(Array) && decoded.size != columns.size)
Expand Down Expand Up @@ -64,7 +64,7 @@ def encode
end
end
unencoded_cursor = (serialized_values.size == 1 ? serialized_values.first : serialized_values)
Base64.strict_encode64(unencoded_cursor.to_json)
Base64.urlsafe_encode64(unencoded_cursor.to_json, padding: false)
end

TIMESTAMP_PREFIX = "0aIX2_" # something random
Expand Down

0 comments on commit 79a6396

Please sign in to comment.