Decode URL Safe Base64 in JavaScript (browser side)

自作多情 提交于 2019-11-29 06:38:29

For posterity,

atob(data.replace(/_/g, '/').replace(/-/g, '+'))

As stated by the spec https://tools.ietf.org/html/rfc4648#section-5 however because this uses atob() it does not support unicode characters and thus requires a polyfill.

Finally found it. This does URL Safe decoding

https://github.com/dankogai/js-base64

decodeURIComponent(atob(data))

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!