Skip to content

base64url variant of btoa/atob #351

@beverloo

Description

@beverloo

The HTML specification has two methods for converting between a unicode string to a base64-encoded representation of it, and vice versa.

https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowbase64-btoa

The URL-safe base64 encoding (base64url), also defined in RFC4648, has been adopted by a few specifications recently. Examples include the Push API (PushSubscription serialization) and various parameters of JWK objects (EME, Web Crypto).

https://tools.ietf.org/html/rfc4648#section-5

While the contents aren't immediately intended for consumption by the web app, those which would like to now need their own conversion methods. (As trivial as that may be.)

The naming of btoa/atob doesn't make it very extensible. We could either add an argument (optional boolean urlsafe = false), or introduce methods analogous to them for the different encoding - urlbtoa/urlatob? I prefer the former.

I'd be happy to generate a pull request if you think adding these makes sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    addition/proposalNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interest

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions