Decode URL Safe Base64 in JavaScript (browser side)

后端 未结 3 2077

I am using Gmail\'s API to get emails from my account. The body of the message is delivered in a \"URL safe base64\" format. What is the best way to decode this for use? I h

相关标签:
3条回答
  • 2020-12-16 16:45

    decodeURIComponent(atob(data))

    0 讨论(0)
  • 2020-12-16 16:50

    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.

    0 讨论(0)
  • 2020-12-16 16:51

    Finally found it. This does URL Safe decoding

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

    0 讨论(0)
提交回复
热议问题