Re: encode/decode support for base64url

Florents Tselai <florents.tselai@gmail.com>

From: Florents Tselai <florents.tselai@gmail.com>
To: Daniel Gustafsson <daniel@yesql.se>
Cc: Aleksander Alekseev <aleksander@timescale.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>, Przemysław Sztoch <przemyslaw@sztoch.pl>
Date: 2025-03-10T12:43:15Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Add support for base64url encoding and decoding

On Mon, Mar 10, 2025, 14:32 Daniel Gustafsson <daniel@yesql.se> wrote:

> > On 10 Mar 2025, at 12:28, Florents Tselai <florents.tselai@gmail.com>
> wrote:
>
> > Here's a C implementation for this, along with some tests and
> documentation.
> > Tests are copied from cpython's implementation of urlsafe_b64encode and
> urlsafe_b64decode.
>
> +         <function>base64url_encode</function> (
> <parameter>input</parameter> <type>bytea</type> )
>
> Shouldn't this be modelled around how base64 works with the encode() and
> decode() functions, ie encode('123\001', 'base64')?
>
>         https://www.postgresql.org/docs/devel/functions-binarystring.html
>
> --
> Daniel Gustafsson
>

Oh well - you're probably right.
I guess I was blinded by my convenience.
Adding a 'base64url' option there is more appropriate.