mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Update xml2js
This commit is contained in:
parent
b3498a888d
commit
cfa25dc655
@ -79,7 +79,7 @@
|
|||||||
"uglify-js": "3.17.4",
|
"uglify-js": "3.17.4",
|
||||||
"uuid": "9.0.0",
|
"uuid": "9.0.0",
|
||||||
"ws": "7.5.6",
|
"ws": "7.5.6",
|
||||||
"xml2js": "0.5.0"
|
"xml2js": "0.6.0"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"bcrypt": "5.1.0"
|
"bcrypt": "5.1.0"
|
||||||
|
@ -33,14 +33,7 @@ module.exports = function(RED) {
|
|||||||
parseString(value, options, function (err, result) {
|
parseString(value, options, function (err, result) {
|
||||||
if (err) { done(err); }
|
if (err) { done(err); }
|
||||||
else {
|
else {
|
||||||
// TODO: With xml2js@0.5.0, they return an object with
|
RED.util.setMessageProperty(msg,node.property,result);
|
||||||
// a null prototype. This could cause unexpected
|
|
||||||
// issues. So for now, we have to reconstruct
|
|
||||||
// the object with a proper prototype.
|
|
||||||
// Once https://github.com/Leonidas-from-XIV/node-xml2js/pull/674
|
|
||||||
// is merged, we can revisit and hopefully remove this hack
|
|
||||||
value = fixObj(result)
|
|
||||||
RED.util.setMessageProperty(msg,node.property,value);
|
|
||||||
send(msg);
|
send(msg);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
@ -52,18 +45,4 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("xml",XMLNode);
|
RED.nodes.registerType("xml",XMLNode);
|
||||||
|
|
||||||
|
|
||||||
function fixObj(obj) {
|
|
||||||
const res = {}
|
|
||||||
const keys = Object.keys(obj)
|
|
||||||
keys.forEach(k => {
|
|
||||||
if (typeof obj[k] === 'object' && obj[k]) {
|
|
||||||
res[k] = fixObj(obj[k])
|
|
||||||
} else {
|
|
||||||
res[k] = obj[k]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
"tough-cookie": "4.1.2",
|
"tough-cookie": "4.1.2",
|
||||||
"uuid": "9.0.0",
|
"uuid": "9.0.0",
|
||||||
"ws": "7.5.6",
|
"ws": "7.5.6",
|
||||||
"xml2js": "0.5.0",
|
"xml2js": "0.6.0",
|
||||||
"iconv-lite": "0.6.3"
|
"iconv-lite": "0.6.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user