feat: effective url environment templates work with headers, url and params
This commit is contained in:
15
helpers/templating.ts
Normal file
15
helpers/templating.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Environment } from "~/newstore/environments"
|
||||
|
||||
export default function parseTemplateString(
|
||||
str: string,
|
||||
variables: Environment["variables"]
|
||||
) {
|
||||
if (!variables || !str) {
|
||||
return str
|
||||
}
|
||||
const searchTerm = /<<([^>]*)>>/g // "<<myVariable>>"
|
||||
return decodeURI(encodeURI(str)).replace(
|
||||
searchTerm,
|
||||
(_, p1) => variables.find((x) => x.key === p1)?.value || ""
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user