diff --git a/scripts/generate-http-docs.js b/scripts/generate-http-docs.js index ff6f841..321157a 100644 --- a/scripts/generate-http-docs.js +++ b/scripts/generate-http-docs.js @@ -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; });