@spotinst/spinnaker-deck
Version:
Spinnaker-Deck service, forked with support to Spotinst
10 lines (9 loc) • 411 B
text/typescript
// The native atob() doesn't know how to decode all unicode chars because Strings are 16-bit.
// This escapes the unicode chars after atob() tries to process them, and re-decodes them.
export const decodeUnicodeBase64 = (encodedString: string) =>
decodeURIComponent(
atob(encodedString)
.split('')
.map((char) => '%' + ('00' + char.charCodeAt(0).toString(16)).slice(-2))
.join(''),
);