Skip to content

Commit

Permalink
decode app data as utf8 string to support emojis etc in peer and node…
Browse files Browse the repository at this point in the history
… names
  • Loading branch information
liamcottle committed Jun 2, 2024
1 parent e6d982c commit d55e2b4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1645,18 +1645,24 @@
}

},
decodeBase64ToUtf8String: function(base64) {
// support for decoding base64 as a utf8 string to support emojis and cyrillic characters etc
return decodeURIComponent(atob(base64).split('').map(function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
},
getPeerNameFromAppData: function(appData) {
try {
// app data should be peer name, and our server provides it base64 encoded
return atob(appData);
return this.decodeBase64ToUtf8String(appData);
} catch(e){
return "Anonymous Peer";
}
},
getNodeNameFromAppData: function(appData) {
try {
// app data should be node name, and our server provides it base64 encoded
return atob(appData);
return this.decodeBase64ToUtf8String(appData);
} catch(e){
return "Anonymous Node";
}
Expand Down

0 comments on commit d55e2b4

Please sign in to comment.