diff --git a/packages/hoppscotch-app/helpers/utils/EffectiveURL.ts b/packages/hoppscotch-app/helpers/utils/EffectiveURL.ts index e8e8e08ff..32f10aa56 100644 --- a/packages/hoppscotch-app/helpers/utils/EffectiveURL.ts +++ b/packages/hoppscotch-app/helpers/utils/EffectiveURL.ts @@ -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" diff --git a/packages/hoppscotch-data/src/pathVariables.ts b/packages/hoppscotch-data/src/variables.ts similarity index 85% rename from packages/hoppscotch-data/src/pathVariables.ts rename to packages/hoppscotch-data/src/variables.ts index de747573a..110064706 100644 --- a/packages/hoppscotch-data/src/pathVariables.ts +++ b/packages/hoppscotch-data/src/variables.ts @@ -16,7 +16,7 @@ export type Variables = { }[] const REGEX_ENV_VAR = /<<([^>]*)>>/g // "<>" -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 || "" ) }