mirror of
https://github.com/langgenius/dify.git
synced 2026-07-23 20:18:40 +08:00
22 lines
488 B
TypeScript
22 lines
488 B
TypeScript
'use client'
|
|
|
|
// regex to match the {{}} and replace it with a span
|
|
const regex = /\{\{([^}]+)\}\}/g
|
|
|
|
export const getInputKeys = (value: string) => {
|
|
const keys =
|
|
value.match(regex)?.map((item) => {
|
|
return item.replace('{{', '').replace('}}', '')
|
|
}) || []
|
|
const keyObj: Record<string, boolean> = {}
|
|
// remove duplicate keys
|
|
const res: string[] = []
|
|
keys.forEach((key) => {
|
|
if (keyObj[key]) return
|
|
|
|
keyObj[key] = true
|
|
res.push(key)
|
|
})
|
|
return res
|
|
}
|