django-cursor-pagination icon indicating copy to clipboard operation
django-cursor-pagination copied to clipboard

use urlsafe_b64endcode

Open dtkav opened this issue 6 years ago • 1 comments

I'd like to use the cursors in the query string, but they currently aren't url safe, so some of the characters are url-encoded.

The goal of this diff is to remove the need for url-encoding the cursor.

There are three main changes:

  1. switch to using base64.urlsafe_b64encode and base64.urlsafe_b64decode
  2. strip and re-pad the b64 padding character (=), which would otherwise be url-encoded
  3. fall back to b64decode if urlsafe_b64decode fails (for backwards compatibility)

Let me know what you think!

dtkav avatar Jan 24 '19 03:01 dtkav

Rather than messing around with urlsafe_b64encode, wouldn't it make more sense to do search and replace instead? That would avoid the need to do any fallback and I think the code would be more readable too.

moggers87 avatar Oct 18 '19 21:10 moggers87