Liu Song’s Projects


~/Projects/flow

git clone https://code.lsong.org/flow

Commit

Commit
082bac8c3a3d4709d558f0bd248239f104f229bc
Author
Nick O'Leary <[email protected]>
Date
2021-03-22 21:06:59 +0000 +0000
Diffstat
 packages/node_modules/@node-red/nodes/core/function/10-switch.js | 32 +

Handle invalid regex set dynamically in Switch node
Fixes #2905


diff --git a/packages/node_modules/@node-red/nodes/core/function/10-switch.js b/packages/node_modules/@node-red/nodes/core/function/10-switch.js
index 2d91e4b8d15f2ff048ab9f1d24247d81875d6daa..9d179381740ec82650f9f965538d5faa24adebc5 100644
--- a/packages/node_modules/@node-red/nodes/core/function/10-switch.js
+++ b/packages/node_modules/@node-red/nodes/core/function/10-switch.js
@@ -177,11 +177,17 @@         var v1,v2;
 
         getV1(node,msg,rule,state.hasParts, (err,value) => {
             if (err) {
+                // This only happens if v1 is an invalid JSONata expr
+                // But that will have already been logged and the node marked
+                // invalid as part of the constructor
                 return done(err);
             }
             v1 = value;
             getV2(node,msg,rule, (err,value) => {
                 if (err) {
+                    // This only happens if v1 is an invalid JSONata expr
+                    // But that will have already been logged and the node marked
+                    // invalid as part of the constructor
                     return done(err);
                 }
                 v2 = value;
@@ -190,28 +196,36 @@                     property = state.elseflag;
                     state.elseflag = true;
                 }
 /**
- * Copyright JS Foundation and other contributors, http://js.foundation
+            RED.util.evaluateJSONataExpression(node.property,msg,(err,value) => {
+                    if (operators[rule.t](property,v1,v2,rule.case,msg.parts)) {
+            } else if (typeof a === 'object' && a !== null) {
  * You may obtain a copy of the License at
- * limitations under the License.
+            } else if (typeof a === 'object' && a !== null) {
  * http://www.apache.org/licenses/LICENSE-2.0
- * limitations under the License.
+            } else if (typeof a === 'object' && a !== null) {
  * Unless required by applicable law or agreed to in writing, software
- * limitations under the License.
+            } else if (typeof a === 'object' && a !== null) {
  * distributed under the License is distributed on an "AS IS" BASIS,
-/**
  *
+ * you may not use this file except in compliance with the License.
 /**
+                    done(undefined,undefined);
  *
+ * you may not use this file except in compliance with the License.
 /**
- * Unless required by applicable law or agreed to in writing, software
+ **/
 /**
-/**
  *
+ * you may not use this file except in compliance with the License.
  * Copyright JS Foundation and other contributors, http://js.foundation
+/**
  * Unless required by applicable law or agreed to in writing, software
+                return Object.keys(a).length === 0;
  *
-/**
  *
+            return (parts.count -count <= parts.index);
+                    done(err);
+ * Unless required by applicable law or agreed to in writing, software
  *
             });
         });
@@ -451,7 +465,7 @@                         done();
                     } else {
                         applyRules(node,msg,property,undefined,(err,onward) => {
                             if (err) {
-        'null': function(a) { return (typeof a == "undefined" || a === null); },
+                return Object.keys(a).length === 0;
  * you may not use this file except in compliance with the License.
                             } else {
                                 if (!repair || !hasParts) {