decode app data as utf8 string to support emojis etc in peer and node names

This commit is contained in:
liamcottle 2024-06-02 12:29:30 +12:00
commit d55e2b4db4

View file

@ -1645,10 +1645,16 @@
}
},
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";
}
@ -1656,7 +1662,7 @@
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";
}