✨ Introducing The Forge (#1072)
The Forge allows anyone to easily create their own Typebot Block. Closes #380
This commit is contained in:
12
packages/variables/findUniqueVariableValue.ts
Normal file
12
packages/variables/findUniqueVariableValue.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Variable } from '@typebot.io/schemas'
|
||||
|
||||
export const findUniqueVariableValue =
|
||||
(variables: Variable[]) =>
|
||||
(value: string | undefined): Variable['value'] => {
|
||||
if (!value || !value.startsWith('{{') || !value.endsWith('}}')) return null
|
||||
const variableName = value.slice(2, -2)
|
||||
const variable = variables.find(
|
||||
(variable) => variable.name === variableName
|
||||
)
|
||||
return variable?.value ?? null
|
||||
}
|
||||
Reference in New Issue
Block a user