davidchambers / Base64.js

Polyfill for browsers that don't provide window.btoa and window.atob
Other
492 stars 219 forks source link

Include support for base64url #51

Open mightybyte opened 4 years ago

mightybyte commented 4 years ago

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).

davidchambers commented 4 years ago

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 }
mightybyte commented 4 years ago

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?

davidchambers commented 3 years ago

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