fix interactive bug

This commit is contained in:
2026-03-18 04:12:49 +08:00
parent 903fc5024f
commit 6361bf6651
+6 -14
View File
@@ -227,21 +227,13 @@ async function handleEnter() {
return; return;
} }
// First, check if this URL already exists // If the debounced lookup already found this URL exists, just show it
setStatus('checking…', ''); if (state.currentMeta && state.currentMeta.original_url === url) {
try { setStatus('exists', 'ok');
const lookupRes = await apiGet('/api/lookup?url=' + encodeURIComponent(url)); return;
if (lookupRes.ok) { }
// URL already exists — just show its metadata
const data = await lookupRes.json();
state.currentMeta = data;
renderMeta(data);
setStatus('exists', 'ok');
return;
}
} catch { /* lookup failed, proceed to create */ }
// URL does not exist — attempt to create // Create a new short URL
setStatus('creating…', ''); setStatus('creating…', '');
try { try {
const res = await apiPost('/api/shorten', { url: url }); const res = await apiPost('/api/shorten', { url: url });