Update
This commit is contained in:
parent
3eeb0c1807
commit
7d8b73406a
|
@ -31,15 +31,19 @@ Exp.Trasformapi = (transformerXml, initOptions={}) => {
|
|||
|
||||
function _TransformForInput (transformerTree, initOptions, entityName, upstreamName, dataIn, transformOptions={}) {
|
||||
const globalSets = { ...initOptions.sets, ...transformOptions.sets };
|
||||
// due to a bug in defiant, we need to prefix something to any key starting with '@'...
|
||||
// due to 2 bugs in defiant, we need to rename json keys
|
||||
// <https://stackoverflow.com/questions/68903102/renaming-object-keys-which-are-nested/68903897#68903897>
|
||||
function JsonObjectKeysFix (obj) {
|
||||
// TODO avoid collisions? (even if they're unlikely with what we're doing)
|
||||
return (obj !== undefined && obj !== null ? Object.fromEntries(Object.entries(obj).map( ([key,value]) => {
|
||||
const newKey = (key.startsWith('@') ? `_${key}` : key);
|
||||
key = key.replaceAll(':', '_'); // avoid "XML Parsing Error: prefix not bound to a namespace" on Firefox
|
||||
if (key.startsWith('@')) {
|
||||
// prefix any key starting with '@' with a character
|
||||
key = `_${key}`
|
||||
};
|
||||
return typeof value == "object"
|
||||
? [newKey, JsonObjectKeysFix(value)]
|
||||
: [newKey, value]
|
||||
? [key, JsonObjectKeysFix(value)]
|
||||
: [key, value]
|
||||
})) : obj);
|
||||
}
|
||||
function MakeApiEntityObject (entityName, upstreamName, dataIn) {
|
||||
|
|
|
@ -309,6 +309,7 @@ async function MbViewerInit () {
|
|||
(XPath support for both XML sources, and JSON sources via defiant.js)
|
||||
<br/> * Only slightly better RSS support
|
||||
<br/> * Initial, experimental support for Mastodon profiles (broken)
|
||||
<br/> * Hotfixed a defiant parsing bug on Firefox
|
||||
</p>`, time: '2024-01-24T01:00' }, { content: `<p>
|
||||
Copyright notice: MBViewer uses code borrowed from <a href="https://t.me">t.me</a>,
|
||||
specially modified to handle customized data visualizations in an MB-style.
|
||||
|
|
Loading…
Reference in New Issue