Base64.js icon indicating copy to clipboard operation
Base64.js copied to clipboard

Include support for base64url

Open mightybyte opened this issue 5 years ago • 3 comments

What do you think about adding support for the base64url encoding to this package? The only difference between base64url and base64 is the encoding of the 62nd and 63rd alphabet characters (https://tools.ietf.org/html/rfc4648#page-7). It seems a shame to do a whole separate pass over the string just to make this small change (as is done here https://github.com/joaquimserafim/base64-url/blob/master/index.js#L10).

mightybyte avatar Oct 15 '20 14:10 mightybyte

That sounds good to me, @mightybyte, provided the changes are backwards-compatible.

Do you have a suggestion as to how the package should expose the new functionality? The current API is as follows:

{ btoa :: String -> String, atob :: String -> String }

davidchambers avatar Oct 15 '20 15:10 davidchambers

I don't have anything in mind. I figured you would have more opinions about it than me. Since we don't have to match the existing atob and btoa API it seems like there's a good bit more flexibility. Maybe call them encodeBase64Url and decodeBase64Url or something?

mightybyte avatar Oct 15 '20 17:10 mightybyte

If someone is interested in making this change, I will gladly review a pull request. :)

davidchambers avatar Apr 13 '21 21:04 davidchambers