/** * Smoke test for ApiTest "import cURL" parsing behavior. * * Usage (from repo root): * node scripts/debug-parse-curl-smoke.js * * Note: this script doesn't import Vue component code; it mirrors the key parsing * logic for the reported curl pattern (multi-line with --data-urlencode). */ const VERBOSE_SCRIPT_LOGS = process.env.DEBUG_SCRIPT_LOGS === 'true'; if (!VERBOSE_SCRIPT_LOGS) { console.log = () => {}; console.warn = () => {}; } const sample = `curl --location 'https://3pe.itdida.com/itdida-api/login' \\ --header 'Content-Type: application/x-www-form-urlencoded' \\ --data-urlencode 'password=DQC123456' \\ --data-urlencode 'username=18501750115'`; function normalize(curlCommand) { return curlCommand.trim().replace(/\\\s*\r?\n\s*/g, ' ').replace(/\s+/g, ' '); } function parseDataUrlencode(cleanCurl) { const items = []; const quoted = /--data-urlencode\s+(['"])(.*?)\1/g; let m; while ((m = quoted.exec(cleanCurl)) !== null) items.push(m[2]); return items; } const clean = normalize(sample); const items = parseDataUrlencode(clean); const table = items.map((pair) => { const i = pair.indexOf('='); return { name: pair.substring(0, i), value: pair.substring(i + 1) }; }); console.log('cleanCurl:', clean); console.log('--data-urlencode items:', items); console.log('table:', table);