fix interactive bug

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