mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add exception handing to Change node
Adding exception handling to the change node to prevent node-RED from crashing on invalid regular expressions eg. “*kW” (missing escape before the asterix)
This commit is contained in:
parent
5d43334b1c
commit
655e777a3e
@ -35,9 +35,13 @@ function ChangeNode(n) {
|
||||
|
||||
this.on('input', function (msg) {
|
||||
if (node.action == "change") {
|
||||
node.re = new RegExp(this.from, "g");
|
||||
if (typeof msg[node.property] === "string") {
|
||||
msg[node.property] = (msg[node.property]).replace(node.re, node.to);
|
||||
try {
|
||||
node.re = new RegExp(this.from, "g");
|
||||
if (typeof msg[node.property] === "string") {
|
||||
msg[node.property] = (msg[node.property]).replace(node.re, node.to);
|
||||
}
|
||||
} catch(err) {
|
||||
this.error(err.message);
|
||||
}
|
||||
}
|
||||
//else if (node.action == "replace") {
|
||||
|
Loading…
Reference in New Issue
Block a user