Zum Hauptinhalt springen
claw
am
tools
Werkzeuge
Dokumente
Daoark
EN
Startseite
Startseite
/
Entwicklerwerkzeuge
›
= 0 || !f) nginx.push((inLoc ? ' ' : '') + 'rewrite ' + rm[1].replace(/\^|\$$/g, '') + ' ' + rm[2] + ' last;'); continue; } var rd = line.match(/^Redirect\s+(?:(\d+)\s+)?(\S+)\s+(\S+)/i); if (rd) { nginx.push('location ' + rd[2] + ' { return ' + (rd[1] || '301') + ' ' + rd[3] + '; }'); continue; } var di = line.match(/^DirectoryIndex\s+(.+)/i); if (di) { nginx.push('index ' + di[1].trim() + ';'); continue; } var ed = line.match(/^ErrorDocument\s+(\d+)\s+(.+)/i); if (ed) { nginx.push('error_page ' + ed[1] + ' ' + ed[2].trim() + ';'); continue; } var hs = line.match(/^Header\s+set\s+(\S+)\s+["']?([^"']+)["']?/i); if (hs) { nginx.push('add_header ' + hs[1] + ' "' + hs[2] + '" always;'); continue; } var locM = line.match(/^
/i); if (locM) { inLoc = locM[1]; nginx.push('location ' + inLoc + ' {'); continue; } if (/^<\/Location>/i.test(line) && inLoc) { nginx.push('}'); inLoc = null; continue; } nginx.push('# TODO: ' + line); } var out = nginx.join('\n'); if (out.indexOf('TODO') >= 0) out = '# 提示:包含无法自动转换的指令\n\n' + out; return { result: out, meta: '解析 ' + lines.length + ' 行' }; } form.addEventListener('submit', function(e) { e.preventDefault(); btnMain.disabled = true; var origLabel = btnMain.textContent; btnMain.textContent = '处理中…'; errorMsg.classList.remove('show'); resultArea.classList.remove('show'); try { var out = runTool(); showResult(out.result, out.meta); } catch (err) { showError('错误:' + err.message); } btnMain.disabled = false; btnMain.textContent = origLabel; }); btnClear.addEventListener('click', function() { form.reset(); resultArea.classList.remove('show'); errorMsg.classList.remove('show'); }); })();'''