Bug Fix: Environment modal not displaying expand error warning message
This commit is contained in:
@@ -66,37 +66,36 @@ export const parseBodyEnvVariables = (
|
|||||||
export function parseTemplateStringE(
|
export function parseTemplateStringE(
|
||||||
str: string,
|
str: string,
|
||||||
variables: Environment["variables"],
|
variables: Environment["variables"],
|
||||||
myVariables?: Variables
|
myVariables?: Variables | undefined
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if (!variables || !str || !myVariables) {
|
if (!variables || !str) {
|
||||||
return E.right(str)
|
return E.right(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = str
|
let result = str
|
||||||
let depth = 0
|
let depthEnv = 0
|
||||||
let errorBound = 0
|
let depthVar = 0
|
||||||
|
|
||||||
while (result.match(REGEX_ENV_VAR) != null && depth <= ENV_MAX_EXPAND_LIMIT) {
|
while (result.match(REGEX_ENV_VAR) != null && depthEnv <= ENV_MAX_EXPAND_LIMIT) {
|
||||||
result = decodeURI(encodeURI(result)).replace(
|
result = decodeURI(encodeURI(result)).replace(
|
||||||
REGEX_ENV_VAR,
|
REGEX_ENV_VAR,
|
||||||
(_, p1) => variables.find((x) => x.key === p1)?.value || ""
|
(_, p1) => variables.find((x) => x.key === p1)?.value || ""
|
||||||
)
|
)
|
||||||
depth++
|
depthEnv++
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
if (myVariables) {
|
||||||
* TODO: Create an error statement for variables
|
while (result.match(REGEX_MY_VAR) != null && depthVar <= ENV_MAX_EXPAND_LIMIT) {
|
||||||
*/
|
result = decodeURI(encodeURI(result)).replace(
|
||||||
while (result.match(REGEX_MY_VAR) != null && errorBound <= ENV_MAX_EXPAND_LIMIT) {
|
REGEX_MY_VAR,
|
||||||
result = decodeURI(encodeURI(result)).replace(
|
(_, p1) => myVariables.find((x) => x.key === p1)?.value || ""
|
||||||
REGEX_MY_VAR,
|
)
|
||||||
(_, p1) => myVariables.find((x) => x.key === p1)?.value || ""
|
depthVar++
|
||||||
)
|
}
|
||||||
errorBound++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return depth <= ENV_MAX_EXPAND_LIMIT && errorBound <= ENV_MAX_EXPAND_LIMIT ? E.right(result) : E.left(ENV_EXPAND_LOOP);
|
return depthEnv <= ENV_MAX_EXPAND_LIMIT && depthVar <= ENV_MAX_EXPAND_LIMIT ? E.right(result) : E.left(ENV_EXPAND_LOOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user