Streamline management of API collections #1

Merged
administrator merged 43 commits from feature/script-autogenerate-http into main 2026-08-19 14:54:42 +02:00
Showing only changes of commit f531310718 - Show all commits
+17 -5
View File
@@ -92,6 +92,15 @@ function sanitizeVarName(value) {
.replace(/^([0-9])/, '_$1') || 'value';
}
function parsePlaceholderContent(content) {
const trimmed = String(content).trim();
const dotenvMatch = trimmed.match(/^\$dotenv\s+(.+)$/i);
if (dotenvMatch) {
return { name: dotenvMatch[1].trim(), isDotenv: true };
}
return { name: trimmed, isDotenv: false };
}
function collectPlaceholders(value) {
if (typeof value !== 'string') {
return [];
@@ -100,7 +109,7 @@ function collectPlaceholders(value) {
const regex = /\{\{([^{}]+)\}\}/g;
let match;
while ((match = regex.exec(value)) !== null) {
placeholders.push(match[1]);
placeholders.push(parsePlaceholderContent(match[1]).name);
}
return placeholders;
}
@@ -342,10 +351,13 @@ function buildRequestContent(request, requestName, requestConfig = {}, dotenvVar
if (typeof value !== 'string') {
return value;
}
return value.replace(/\{\{([^{}]+)\}\}/g, (match, name) => {
const normalized = String(name).trim();
if (normalized && dotenvVariables.has(normalized)) {
return `{{$dotenv ${normalized}}}`;
return value.replace(/\{\{([^{}]+)\}\}/g, (match, inner) => {
const placeholder = parsePlaceholderContent(inner);
if (placeholder.isDotenv) {
return match;
}
if (placeholder.name && dotenvVariables.has(placeholder.name)) {
return `{{$dotenv ${placeholder.name}}}`;
}
return match;
});