From 8ec9299641fc2550711c347b7e3063a8fe8e7ee9 Mon Sep 17 00:00:00 2001 From: ANGkeith Date: Sat, 14 Dec 2024 01:47:57 +0800 Subject: [PATCH] fix: variable value beginning with pipe should not be interpreted as file (#1457) --- src/variables-from-files.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/variables-from-files.ts b/src/variables-from-files.ts index a907f7b9..65392059 100644 --- a/src/variables-from-files.ts +++ b/src/variables-from-files.ts @@ -61,11 +61,11 @@ export class VariablesFromFiles { const {type, values} = unpack(val); for (const [matcher, content] of Object.entries(values)) { assert(typeof content == "string", `${key}.${matcher} content must be text or multiline text`); - if (isDotEnv || type === "variable" || (type === null && !/^[/|~]/.exec(content))) { + if (isDotEnv || type === "variable" || (type === null && !/^[/~]/.exec(content))) { const regexp = matcher === "*" ? /.*/g : new RegExp(`^${matcher.replace(/\*/g, ".*")}$`, "g"); variables[key] = variables[key] ?? {type: "variable", environments: []}; variables[key].environments.push({content, regexp, regexpPriority: matcher.length, scopePriority}); - } else if (type === null && /^[/|~]/.exec(content)) { + } else if (type === null && /^[/~]/.exec(content)) { const fileSource = content.replace(/^~\/(.*)/, `${homeDir}/$1`); const regexp = matcher === "*" ? /.*/g : new RegExp(`^${matcher.replace(/\*/g, ".*")}$`, "g"); variables[key] = variables[key] ?? {type: "file", environments: []};