Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core/serverGroup): Default to decoding User Data as text (#5210)
* fix(core/serverGroup): Default to decoding User Data as text
- Loading branch information
1 parent
a6e1f91
commit cd3fe20
Showing
2 changed files
with
34 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// 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(''), | ||
); |