From d707101055f4e7e25c089a6e88108b6424b7fc07 Mon Sep 17 00:00:00 2001 From: Michal Orlik Date: Wed, 6 Mar 2024 18:35:24 +0100 Subject: [PATCH] fix(plugins): custom variable must start with $_ --- src/plugins/CustomVariable.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/plugins/CustomVariable.ts b/src/plugins/CustomVariable.ts index 16c5b6950a2..d20b0e8c0ff 100644 --- a/src/plugins/CustomVariable.ts +++ b/src/plugins/CustomVariable.ts @@ -3,9 +3,19 @@ import { setValueOf } from '~/helpers/customvariables/setValueOf.js'; export const CustomVariableGenerator = (pluginId: string) => ({ async set(variableName: string, value: any) { - await setValueOf(String(variableName), value, {}); + variableName = String(variableName).trim(); + if (variableName.startsWith('$_')) { + await setValueOf(variableName, value, {}); + } else { + throw new Error('Variable name must start with "$_".'); + } }, async get(variableName: string) { - return getValueOf(String(variableName)); + variableName = String(variableName).trim(); + if (variableName.startsWith('$_')) { + return getValueOf(String(variableName)); + } else { + throw new Error('Variable name must start with "$_".'); + } }, }); \ No newline at end of file