diff --git a/static/app.js b/static/app.js index 892fffd..e1be7b3 100644 --- a/static/app.js +++ b/static/app.js @@ -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); - setStatus('exists', 'ok'); - return; - } - } catch { /* lookup failed, proceed to create */ } + // If the debounced lookup already found this URL exists, just show it + if (state.currentMeta && state.currentMeta.original_url === url) { + setStatus('exists', 'ok'); + return; + } - // URL does not exist — attempt to create + // Create a new short URL setStatus('creating…', ''); try { const res = await apiPost('/api/shorten', { url: url });