Fixed . in effect stat targets breaking entire sheet

This commit is contained in:
Stefan Zermatten
2022-02-22 17:30:45 +02:00
parent ee2b400ee6
commit 4c6d70b084
2 changed files with 5 additions and 1 deletions

View File

@@ -5,12 +5,16 @@ import computeVariableAsConstant from './computeVariable/computeVariableAsConsta
import computeVariableAsClass from './computeVariable/computeVariableAsClass.js';
import computeVariableAsToggle from './computeVariable/computeVariableAsToggle.js';
import computeImplicitVariable from './computeVariable/computeImplicitVariable.js';
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
export default function computeVariable(computation, node){
const scope = computation.scope;
if (!node.data) node.data = {};
aggregateLinks(computation, node);
combineAggregations(computation, node);
// Don't add to the scope if the node id is not a legitimate variable name
// Without this `some.thing` could break the entire sheet as a database key
if (!VARIABLE_NAME_REGEX.test(node.id)) return;
if (node.data.definingProp){
// Add the defining variable to the scope
scope[node.id] = node.data.definingProp

View File

@@ -1,4 +1,4 @@
// Must contain a letter, and be made of word characters only
const VARIABLE_NAME_REGEX = /^\w*[a-z]\w*$/i;
const VARIABLE_NAME_REGEX = /^[a-z][\w-]*$/i;
export default VARIABLE_NAME_REGEX;