Renamed file and refactored, added new TODO

This commit is contained in:
Jason Casareno
2022-08-01 13:07:27 -07:00
parent 5538b9a5b9
commit 7bf66d8339
2 changed files with 7 additions and 4 deletions

View File

@@ -14,7 +14,7 @@ import {
HoppRESTHeader,
HoppRESTParam,
} from "@hoppscotch/data"
import { parseTemplateStringV } from "@hoppscotch/data/src/pathVariables"
import { parseTemplateStringV } from "@hoppscotch/data/src/variables"
import { arrayFlatMap, arraySort } from "../functional/array"
import { toFormData } from "../functional/formData"
import { tupleToRecord } from "../functional/record"

View File

@@ -16,7 +16,7 @@ export type Variables = {
}[]
const REGEX_ENV_VAR = /<<([^>]*)>>/g // "<<myVariable>>"
const REGEX_PATH_VAR = /{{([^}]*)}}/g // "{{myVariable}}"
const REGEX_MY_VAR = /{{([^}]*)}}/g // "{{myVariable}}"
/**
* How much times can we expand environment variables
@@ -49,9 +49,12 @@ export function parseTemplateStringEV(
depth++
}
while (result.match(REGEX_PATH_VAR) != null && depth <= ENV_MAX_EXPAND_LIMIT) {
/**
* TODO: Create an error state when there is a suspected loop while recursively expanding these variables
*/
while (result.match(REGEX_MY_VAR) != null && depth <= ENV_MAX_EXPAND_LIMIT) {
result = decodeURI(encodeURI(result)).replace(
REGEX_PATH_VAR,
REGEX_MY_VAR,
(_, p1) => pathVariables.find((x) => x.key === p1)?.value || ""
)
}