if you put null into the parse block in the dictionaries extension it errors with Uncaught TypeError: Cannot convert undefined or null to object
on top of that values such as "text" and 20 produce unexpected results
possible patch:
dict_parse({ OBJ, DICT }) {
let dict = null;
try {
dict = JSON.parse(OBJ);
+ if (typeof dict !== 'object') dict = {error: 'data must be an object or array'};
} catch (e) {
dict = {"error": String(e)};
}
+ // add the length value if and only if this is an array
+ if (Array.isArray(dict)) {
+ const entries = Object.entries(dict)
+ entries.push(['length', dict.length])
+ dict = Object.fromEntries(entries)
+ }
dictionaries.set(DICT, new Map(Object.entries(dict)));
}
if you put
nullinto the parse block in the dictionaries extension it errors withUncaught TypeError: Cannot convert undefined or null to objecton top of that values such as
"text"and20produce unexpected resultspossible patch:
dict_parse({ OBJ, DICT }) { let dict = null; try { dict = JSON.parse(OBJ); + if (typeof dict !== 'object') dict = {error: 'data must be an object or array'}; } catch (e) { dict = {"error": String(e)}; } + // add the length value if and only if this is an array + if (Array.isArray(dict)) { + const entries = Object.entries(dict) + entries.push(['length', dict.length]) + dict = Object.fromEntries(entries) + } dictionaries.set(DICT, new Map(Object.entries(dict))); }