Merge pull request #3632 from node-red-hitachi/fix-inject-of-JSONata

Fix JSONata evaluation of inject button
This commit is contained in:
Nick O'Leary 2022-06-09 16:00:23 -05:00 committed by GitHub
commit 73ff7e2de4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -109,9 +109,10 @@ module.exports = function(RED) {
if (!property) return;
if (valueType === "jsonata") {
if (p.exp) {
if (p.v) {
try {
var val = RED.util.evaluateJSONataExpression(p.exp, msg);
var exp = RED.util.prepareJSONataExpression(p.v, node);
var val = RED.util.evaluateJSONataExpression(exp, msg);
RED.util.setMessageProperty(msg, property, val, true);
}
catch (err) {

View File

@ -906,6 +906,7 @@ describe('inject node', function() {
msg.should.have.property("str1", "1"); //injected prop
msg.should.have.property("num1", 1); //injected prop
msg.should.have.property("bool1", true); //injected prop
msg.should.have.property("jsonata1", "AB"); //injected prop
helper.clearFlows().then(function() {
done();
@ -919,6 +920,7 @@ describe('inject node', function() {
{p:"str1", v:"1", vt:"str"}, //new prop
{p:"num1", v:"1", vt:"num"}, //new prop
{p:"bool1", v:"true", vt:"bool"}, //new prop
{p:"jsonata1", v:'"A" & "B"', vt:"jsonata"}, //new prop
]})
.expect(200).end(function(err) {
if (err) {