js: make non-payload data more encoding-tolerant
-- * src/Helpers.js: As non-payload data might come in different encodings, a conversion has been introduced that worked in most cases. Data like the userid might come in different encodings, which we don't know of. For now, a try..catch returns the data as they are if the utf-8 decoding fails. Sometimes this yields the correct result, sometimes it may not work, but it won't stop the whole operation anymore.
This commit is contained in:
parent
766d42c248
commit
28086252f1
@ -115,7 +115,14 @@ export function isLongId (value){
|
|||||||
*/
|
*/
|
||||||
export function decode (property){
|
export function decode (property){
|
||||||
if (typeof property === 'string'){
|
if (typeof property === 'string'){
|
||||||
|
try {
|
||||||
return decodeURIComponent(escape(property));
|
return decodeURIComponent(escape(property));
|
||||||
|
}
|
||||||
|
catch (error){
|
||||||
|
if (error instanceof URIError) {
|
||||||
|
return property;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (Array.isArray(property)){
|
} else if (Array.isArray(property)){
|
||||||
let res = [];
|
let res = [];
|
||||||
for (let arr=0; arr < property.length; arr++){
|
for (let arr=0; arr < property.length; arr++){
|
||||||
|
Loading…
Reference in New Issue
Block a user